How to change excerpt length in WordPress

By default, WordPress displays the first 55 words from the post content for the excerpt. But sometimes we need to show more or fewer words. This tutorial shows you how to change the default excerpt length of your theme.

Simply open your functions.php and put this PHP code-

 * Control excerpt length.
function custom_excerpt_length( $length ) {
	return 15;
add_filter( 'excerpt_length', 'custom_excerpt_length', 999 );

This function where it specifies ‘return 15’ is to change the excerpt length to 15 words. You may change the ‘return’ value to any number as you like.

0 Points

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.