Used By
Used By | Description |
---|---|
wp-includes/formatting.php: wp_trim_excerpt() | Generates an excerpt from the content, if needed. |
Filters the maximum number of words in a post excerpt.
(int) The maximum number of words. Default 55.
Use this filter if you want to change the default excerpt length.
To change excerpt length, add the following code to functions.php
file in your theme adjusting the “20” to match the number of words you wish to display in the excerpt:
function mytheme_custom_excerpt_length( $length ) { return 20; } add_filter( 'excerpt_length', 'mytheme_custom_excerpt_length', 999 );
Make sure to set the priority correctly, such as 999, otherwise the default WordPress filter on this function will run last and override what you set here.
Version | Description |
---|---|
2.7.0 | Introduced. |
© 2003–2019 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/hooks/excerpt_length