How to change length of post excerpt in wordpress theme

How to change length of post excerpt in wordpress theme

To change the length of the post excerpt in a WordPress theme, you can modify the theme’s functions.php file. First, access the functions.php file by navigating to Appearance > Theme Editor in your WordPress dashboard. Then, add the following code to the file:

function custom_excerpt_length($length) {
return 30; // Change 30 to the desired number of words
}
add_filter('excerpt_length', 'custom_excerpt_length');

This code will adjust the default excerpt length. The 30 can be changed to any number, depending on how many words you want your excerpt to display. Once you save the changes, the new excerpt length will be applied across your site. Make sure to back up your functions.php file before editing to prevent any issues. Alternatively, some themes allow you to modify excerpt length directly through the theme customizer or settings panel.

How to use post excerpt in WordPress Twenty Fifteen theme

How to Use Post Excerpts in the WordPress Twenty Fifteen Theme

The WordPress Twenty Fifteen theme offers a clean, content-focused design perfect for blogging. If you want to show a short preview of your posts on the blog or archive pages instead of the full content, using post excerpts is the way to go.

This guide will walk you through how to enable and display post excerpts in the Twenty Fifteen theme. You’ll learn how to manually add excerpts in the WordPress editor, customize the length and appearance of excerpts, and ensure your theme is properly set up to display them. Whether you’re looking to create a more streamlined homepage or improve user navigation, this tutorial will help you make the most of the post excerpt feature.

WordPress blog excerpt not working in Themes

Some of the themes in wordpress does not display excerpt on blog page, category pages or archive pages. This is because theme does not include the experts code in the theme file.

This is a very simple tutorial that anyone can implement and take advantage of this built-in feature. The benefit of implementing this tutorial is that it decreases page load time and it increases the pageview count.

So we will have to update theme as per our need. For this process we will have to edit index.php file, archive.php file, and category.php file and find the code

<?php the_content(); ?>

If this is there then replace it with

<?php the_excerpt(); ?>

 

Enable AJAX Submit in GravityForms in wordpress

Enable AJAX Submit in GravityForms in wordpress

To enable AJAX form submission in Gravity Forms on your WordPress site, simply navigate to the form settings and enable the AJAX option.

This allows users to submit forms without a page reload, enhancing user experience and improving performance. To activate AJAX, use the shortcode [gravityform id="1" ajax="true"], replacing "1" with your actual form ID.

Alternatively, if adding the form via PHP, use gravity_form(1, false, false, false, '', true);.

Enabling AJAX ensures smoother interactions, reduces page load times, and provides instant feedback, making it ideal for modern, dynamic websites.

Change woocommerce price position

If want to change the position of the price in wocommerce then this is possible. You can it easy in adding little code in the functions.php file.

If you want to put price near add to cart button then please add following code to Functions.php file of your child theme (or parent theme, if not using a child theme)- you can use Dashboard -> Appearance > Editor or direct FTP

remove_action( ‘woocommerce_single_product_summary’, ‘woocommerce_template_single_price’, 10 );
add_action( ‘woocommerce_single_product_summary’, ‘woocommerce_template_single_price’, 29 );

Show only single category posts on WordPress archive page

To display only a single category’s posts on a WordPress archive page, you can modify your theme’s functions.php file or create a custom template. The best approach is to use the pre_get_posts hook, which allows you to filter the query before WordPress retrieves posts. Here’s an optimized way to do it:

function filter_archive_by_category( $query ) {
if ( !is_admin() && $query->is_archive() && $query->is_main_query() ) {
$query->set( 'cat', 12 ); // Replace 12 with your category ID
}
}
add_action( 'pre_get_posts', 'filter_archive_by_category' );

This snippet ensures that only posts from a specific category appear on archive pages while maintaining performance and compatibility. You can replace the category ID (12) with the desired category’s ID, which can be found in the WordPress admin panel under Posts > Categories. This method is ideal for keeping your theme lightweight and SEO-friendly without modifying core files.

CSS Media Queries for iPads & iPhones

Sometimes we got very confusion while developing responsive work. When we apply the breakpoints for iPad and iPhone that does not works properly. As per my experience while searching on the Internet I found some useful information regarding the media queries. I applied those and that works fine for me. So today I am going to add the media queries here for the same.

iPad Media Queries

iPad Media Queries (All generations – including iPad mini)

 

iPad in portrait & landscape


@media only screen
and (min-device-width : 768px)
and (max-device-width : 1024px) { /* STYLES GO HERE */}

iPad in landscape


@media only screen
and (min-device-width : 768px)
and (max-device-width : 1024px)
and (orientation : landscape) { /* STYLES GO HERE */}

iPad in portrait


@media only screen
and (min-device-width : 768px)
and (max-device-width : 1024px)
and (orientation : portrait) { /* STYLES GO HERE */ }

Retina iPad in landscape


@media only screen
and (min-device-width : 768px)
and (max-device-width : 1024px)
and (orientation : landscape)
and (-webkit-min-device-pixel-ratio: 2) { /* STYLES GO HERE */}

Retina iPad in portrait


@media only screen
and (min-device-width : 768px)
and (max-device-width : 1024px)
and (orientation : portrait)
and (-webkit-min-device-pixel-ratio: 2) { /* STYLES GO HERE */ }

iPad mini Media Queries

iPad mini in portrait & landscape


@media only screen
and (min-device-width : 768px)
and (max-device-width : 1024px)
and (-webkit-min-device-pixel-ratio: 1) { /* STYLES GO HERE */}

iPad mini in landscape


@media only screen
and (min-device-width : 768px)
and (max-device-width : 1024px)
and (orientation : landscape)
and (-webkit-min-device-pixel-ratio: 1) { /* STYLES GO HERE */}

iPad mini in portrait


@media only screen
and (min-device-width : 768px)
and (max-device-width : 1024px)
and (orientation : portrait)
and (-webkit-min-device-pixel-ratio: 1) { /* STYLES GO HERE */ }

iPad mini Resolution


Screen Width = 768px (CSS Pixels)
Screen Height = 1024px (CSS Pixels)

Screen Width = 768px (Actual Pixels)
Screen Height = 1024px (Actual Pixels)

Device-pixel-ratio: 1

iPhone Media Queries

iPhone 6 Media Queries

iPhone 6 in portrait & landscape


@media only screen
and (min-device-width : 375px)
and (max-device-width : 667px) { /* STYLES GO HERE */}

iPhone 6 in landscape


@media only screen
and (min-device-width : 375px)
and (max-device-width : 667px)
and (orientation : landscape) { /* STYLES GO HERE */}

iPhone 6 in portrait


@media only screen
and (min-device-width : 375px)
and (max-device-width : 667px)
and (orientation : portrait) { /* STYLES GO HERE */ }

How to Add Google Translate in WordPress

Today I will show you how you can add google translator plugin on the wordpress site in easy steps. First of all you have install this plugin Google Language Translator

After activating the plugin go to Settings » Google Language Translator to configure the plugin.

Make sure that the plugin is activated. After that you need to select your website’s default language, and the languages you want to be available for translation. Once you are done simply save your plugin settings.

Now after then you have to use the widget code on the widget section to display the translator on the site (simply drag and drop).

If you want to do that custom then you need to copy the code as per below screenshot and paste in your template file.

Now you have done you website in multi language option….. Thanks!!

Get page id in wordpress

Here is the tips for getting page id in wordpress. First of all I will show page id in admin area.

Go to the pages and clcik on that, then you can see all pages list. Look the below screenhsot.

After then click on the desired page and you can see the page id on the address bar as I have marked. attached screenshot.

If you want to check page id on the front side then you should use the code. Use the blow wordpress function . It will give you the page id on the pages
get_the_ID();

More detail you can get here

If you want to show page id only for specific page then you can use the below code
<?php if(get_the_ID() == ‘475’) {?>
I am your page
<?php } ?>

Burger menu not working on ipad/tablet in wordpress

Burger menu not working on ipad/tablet in wordpress

If you are working with wordpress enfold theme then may be you get the issue of menu on the tablet/ipad in landscape mode. Them menu does not appears as a burger so try this media query, may be it will help :


@media only screen and (max-width: 1024px) { /*** put your css code here ****/}