I want my excerpt to be shorter than the default 55 characters. So I found this code in the Wordpress documentation:

 * Filter the except length to 20 words.
 * @param int $length Excerpt length.
 * @return int (Maybe) modified excerpt length.
function wpdocs_custom_excerpt_length( $length ) {
    return 20;
add_filter( 'excerpt_length', 'wpdocs_custom_excerpt_length', 999 );

How do I apply this filter to my code, which looks like this:

<?php the_excerpt(); ?>

1 Answer 1


Just put the code inside functions.php that lives in your theme folder:

  • Okay I did that and it does not seem to have any effect. Even if I change the 999 to 20, the pursue of which I'm not sure about. I presume its the argument $lenght, but even if it is, I don't see how it is being used inside the function wpdocs_custom_excerpt_length Commented Jan 14, 2017 at 14:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.