excerpt_length filter-hookWP 2.7.0

Filters the maximum number of words in a post excerpt.

Usage

add_filter( 'excerpt_length', 'wp_kama_excerpt_length_filter' );

/**
 * Function for `excerpt_length` filter-hook.
 * 
 * @param int $number The maximum number of words.
 *
 * @return int
 */
function wp_kama_excerpt_length_filter( $number ){

	// filter...
	return $number;
}
$number(int)
The maximum number of words.
Default: 55

Changelog

Since 2.7.0 Introduced.

Where the hook is called

wp_trim_excerpt()
excerpt_length
wp-includes/formatting.php 3890
$excerpt_length = (int) apply_filters( 'excerpt_length', $excerpt_length );

Where the hook is used in WordPress

wp-includes/blocks/latest-posts.php 174
remove_filter( 'excerpt_length', 'block_core_latest_posts_get_excerpt_length', 20 );
wp-includes/blocks/latest-posts.php 49
add_filter( 'excerpt_length', 'block_core_latest_posts_get_excerpt_length', 20 );