WordPress.org

Forums

Changing 120 word default of the_excerpt (8 posts)

  1. fx3000
    Member
    Posted 8 years ago #

    Is there a way to change the 120 word default of the_excerpt? I'd like to change it so that it is always 40 or 50 words.

  2. moshu
    Member
    Posted 8 years ago #

    You can edit the core files - never advisable...
    You can use a plugin, like
    http://guff.szub.net/2005/02/26/the-excerpt-reloaded/

  3. fx3000
    Member
    Posted 8 years ago #

    moshu,do you know where this is in the core files? I'm new to WordPress.

  4. Where did you get the idea that it defaulted to 120 words? Near as I can tell, it defaults to 55 words.

    functions-formatting.php - function name is wp_trim_excerpt

  5. war59312
    Member
    Posted 8 years ago #

    From the plug-in above, I suppose. ;)

    Displays defaults: 120 word excerpt; allow anchor (<a>) tag; ‘excerpt’ as filter type, use “(more…)” as more link if excerpt less than content; fake content as excerpt unless post has an excerpt.</a>

  6. moshu
    Member
    Posted 8 years ago #

    The Codex says so (120) - though I've never counted :)
    http://codex.wordpress.org/Template_Tags/the_excerpt

  7. jbbrwcky
    Member
    Posted 8 years ago #

    The code says 55 though - I also tried changing it to a lesser number, doesn't seem to work in certain circumstances. Those include - putting a huge amount of text in, say the same as the article, and the_excerpt() prints the whole thing out. Weird.

  8. Kafkaesqui

    Posted 8 years ago #

    First, the Codex (and my plugin's) documentation says 120 because that is what it originally was. But this was changed a while back from 120 to the current 55. There was a brief period where it was 70, but we don't talk about that... ;)

    Second, word count is always going to be an iffy affair. It's just the nature of this sort of thing.

    Finally, the_excerpt() *summarizes* only when it extracts an excerpt from a post's content. If you place something in the post editor's optional excerpt field, not only will this become your excerpt (naturally), but the_excerpt() assumes you want it all, and will not....excerpt the excerpt.

    EDIT: I've visited the obvious Codex docs where the excerpt word count is referenced and updated these. But please, if you see something on Codex that is incorrect and you know what it should be, feel free to change it. Just like the support forums, the Codex documents are a community effort.

Topic Closed

This topic has been closed to new replies.

About this Topic