Change post excerpt length in WordPress

By default in WordPress, the length of the excerpt is 55 words.
However, what if you wanted to show more or less than 55 words for the post excerpt for this we have a small snippet that will help to change the length of the excerpt to 30 words. You can adjust the limit of words as required.
Insert the code to function.php file in the child theme.

//Change the default excerpt length(default is 55 words) to 30 words

function wps_change_excerpt_length( $length ) {
    return 30;

add_filter( 'excerpt_length', 'wps_change_excerpt_length', 9999);

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top