How to change the WordPress default excerpt length

How to change the WordPress default excerpt length

This snippet will let you define a new custom default excerpt length for the WordPress excerpts output.
The following example will set the default excerpt length to 20 characters.

Instructions
Add this code to your functions.php file.

function new_excerpt_length($length) {
     return 20;
}
add_filter('excerpt_length', 'new_excerpt_length');

WordPress Snippet Info

Tested with Wordpress v. 4.8
Last Modified: 15.05.2018
Last Reviewed: 15.05.2018

How to change the WordPress default excerpt length
4.3 (85.88%) 17 vote[s]
Please report broken snippets.
Report Broken Snippet
WordPress Hosting