WordPress – Change Post Excerpt Length

wordpress-Excerpt-Length

Default WordPress Post Excerpt Length

By default excerpt length of posts is set to return 55 words. But you may wish to change this value. In this tutorial, I will explain how to change the post excerpt length in WordPress.

How To Change Post Excerpt Length

Suppose, we want to change the excerpt length to 40 words.
Add following codes in functions.php file of your theme.

1
2
3
4
5
6
7
/**
* Change the excerpt length to 40 words.
*/

function custom_excerpt_length( $length ) {
  return 40;
}
add_filter( 'excerpt_length', 'custom_excerpt_length', 999 );

Done!!
Hope this article was helpful to you.

Related Posts

Leave a Reply

Your email address will not be published. Required fields are marked *