What I'm using-
WAMP, clean install of WordPress 4.3.1(No plugins) and starter theme - Underscore.

What I'm trying to achieve-
I want to have blog post, that shows only the excerpt, so I've modified content.php and change

        the_content( sprintf(
            /* translators: %s: Name of current post. */
            wp_kses( __( 'Continue reading %s <span class="meta-nav">&rarr;</span>', 'cthulhu' ), array( 'span' => array( 'class' => array() ) ) ),
            the_title( '<span class="screen-reader-text">"', '"</span>', false )
        ) );


<?php the_excerpt(); ?>

Now, I'm able to see my custom excerpt, but wordpress doesn't limit the lenght of excerpt - > I've puted 100 words to Excerpt and there's seems to be no limit in content (which should be 55 words by default).

I've also tried to add function to functions.php

function custom_excerpt_length( $length ) {
    return 20;
add_filter( 'excerpt_length', 'custom_excerpt_length', 999 );

it doesn't work.

I've also tried different themes - all version of Twenty- and it's still same.

Maybe I'm just to tired, but I'm struggling with this so hard...

1 Answer 1


the_excerpt() ...

Displays the excerpt of the current post after applying several filters to it including auto-p formatting which turns double line-breaks into HTML paragraphs. It uses get_the_excerpt() to first generate a trimmed-down version of the full post content should there not be an explicit excerpt for the post.

get_the_excerpt() applies the get_the_excerpt filter, to which wp_trim_excerpt() is attached.

If you look at that function you'll notice that excerpt_length is only applied when the excerpt is generated from the post body automatically. Otherwise, the manually written excerpt just passes straight through.

Honestly, since you are writing the excerpts I don't understand why you want to automatically truncate them, but if you must you can add a filter to wp_trim_excerpt using wp_trim_excerpt() as a model.

  • Alright, I've missunderstood the whole excerpt function.
    – Kailo
    Commented Nov 11, 2015 at 14:47
  • The excerpt functionality is confusing.
    – s_ha_dum
    Commented Nov 11, 2015 at 14:49
  • Thank you, s_ha_dum♦, for bringing light to my path. Now I feel utterly stupid. edit: I marked your answer as the right one, since it helped me to understand the basics of this functionality.
    – Kailo
    Commented Nov 11, 2015 at 14:55

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.