Change the_excerpt() word length in WordPress

By default the WordPress the_excerpt() tag displays the first 55 words. To assign a custom length just add the following code to your theme’s functions.php file. The return value in the custom_length function will change the word length of the_excerpt() tag.

function custom_length( $length ) {
	return 30;
}
add_filter( 'excerpt_length', 'custom_length', 999 );

Tested with WordPress version 3.3

Leave a Reply

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