This snippet allows you to control the number of words displayed in WordPress post excerpts. You can customize the excerpt length to maintain consistent content previews across your website.
function wpf_custom_excerpt_length( $length ) {
return 25;
}
add_filter( 'excerpt_length', 'wpf_custom_excerpt_length', 999 );
Tested on
WordPress 6.8
Reported by the author on December 1, 2026. WPFolks has not verified this.
Not tested against WordPress 7.1.5. It may still work.
