Codex

Plugin API/Filter Reference/excerpt length

Contents

Description

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

Examples

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.

Change Log

Source File

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

Related

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