0

So I'm trying to change the standard post excerpt length.

Every single blog post on the web tells me to do it with a filter like this:

add_filter( 'excerpt_length', 'custom_excerpt_length', 999 );
function custom_excerpt_length( $length ) {
return 15; // Length of the excerpt in number of words
}

Problem is there is no change to the excerpt length. All the text is being output and not just 15 words. I have no idea why this doesn't work when it's supposed to be the solution.

I'm using <?php the_excerpt(); ?> in the post loop on home.php, category.php and tag.php to output the excerpt.

  • 1
    excerpt_length only applies to the automatically generated excerpt. If you have one entered into the Excerpt box it won't be affected. You're saying that all the text is appearing though? Are you certain you're using the_excerpt() and not the_content()? – Jacob Peattie Apr 4 '18 at 12:51
  • Aha. That explains it. With "All the text" I mean all the text that I have entered in the excerpt textarea for a custom excerpt. How would I limit the amount of words for the entered custom excerpt then? – Skovsgaard Apr 4 '18 at 12:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.