excerpt_length
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
excerpt_length
wp-includes/formatting.php 4010
$excerpt_length = (int) apply_filters( 'excerpt_length', $excerpt_length );
wp-includes/blocks/latest-posts.php 161
$excerpt_length = (int) apply_filters( 'excerpt_length', $block_core_latest_posts_excerpt_length );
Where the hook is used in WordPress
wp-includes/blocks/latest-posts.php 201
remove_filter( 'excerpt_length', 'block_core_latest_posts_get_excerpt_length', 20 );
wp-includes/blocks/latest-posts.php 58
add_filter( 'excerpt_length', 'block_core_latest_posts_get_excerpt_length', 20 );
wp-includes/blocks/post-excerpt.php 116
add_filter( 'excerpt_length', 'block_core_post_excerpt_excerpt_length', PHP_INT_MAX );
wp-includes/blocks/post-excerpt.php 53
add_filter( 'excerpt_length', 'block_core_post_excerpt_excerpt_length', PHP_INT_MAX );
wp-includes/blocks/post-excerpt.php 57
remove_filter( 'excerpt_length', 'block_core_post_excerpt_excerpt_length', PHP_INT_MAX );