Codex tools: Log in
Contents |
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:
function custom_excerpt_length( $length ) {
return 20;
}
add_filter( 'excerpt_length', 'custom_excerpt_length', 999 );
Make sure to set the priority correctly, else the default WordPress filter on this function will run last and override what you set here.
wp_trim_excerpt() is located in wp-includes/formatting.php.