The WPFolks app is out on iPhone and Android. Free, no ads. Download on the App Store Get it on Google Play
Skip to main content
Login Join
Snippet · PHP

Add Custom Excerpt Length in WordPress

Shared by Amit Dholiya · December 1, 2026 · @excerpt_length

4 views
1 upvote
Back to Snippets

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.

Know a different way to do this? Add your approach as a variation so folks can compare them side by side.
Submit a variation

0 comments

Proudly supported by