How To Change Excerpt Length In WordPress.

      2 Comments on How To Change Excerpt Length In WordPress.
<p>When developing a wordpress site you might have worked with WordPress post excerpts “the_excerpt()”. Basically excerpt is using for displaying short summary of a post. We use <?php the_excerpt();?> for displaying post excerpts.
Default excerpts length is 55 words, that means it will display 55 words or more in most WordPress index pages and archive pages.
Here I’m going to show you how to change the excerpt length to fit your blog/site needs. You can increase or decrease the length of excerpt by adding a small filter function into your theme’s function.php file.</p>
<?php function new_excerpt_length($len)
{
return 25;
}
add_filter('excerpt_length', 'new_excerpt_length');
?>

just add the above code at the bottam of your function.php template. To access function.php, follow the below steps,

  1. Login to WordPress dashboard.
  2. Click Editor from Appearance tab.
  3. Then select function.php from the left side menu.
If you couldn’t see function.php file, then please refer the below image.
Change Excerpt Length

Above code will shorten your excerpt into 25 words. Now you can change the number 25 with the length you need.

Thats all. You did it. Enjoy…

2 thoughts on “How To Change Excerpt Length In WordPress.

Leave a Reply