Attention Interested in functions, hooks, classes, or methods? Check out the new WordPress Code Reference!

Plugin API/Filter Reference/excerpt length


This filter is used by wp_trim_excerpt() function. By default the excerpt length is set to return 55 words.


To change excerpt length, add the following code to functions.php file in your theme adjusting the "20" to match the number of words you wish to display in the excerpt:

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

Make sure to set the priority correctly, such as 999, else the default WordPress filter on this function will run last and override what you set here.

Change Log

Source File

wp_trim_excerpt() is located in wp-includes/formatting.php.


This page is marked as incomplete. You can help Codex by expanding it.