Tech on Tour header image 2

WordPress get_excerpt – show more words

January 3rd, 2008 by · 4 Comments


the get_excerpt function on WordPress shows the first 55 words of your post, striped out of any special formatting eg: links, bold, etc.  I wanted to change it for a blog I was developing so I traced it back to the function wp_trim_excerpt in the file \wp-includes\formatting.php. In this file you can change the value from 55 to , in my case 100. Just change the line 786 which should look like this  $excerpt_length = 55;

Please remember that this will change the default value for all you excerpts.

UPDATED:  See Mike Schinkel’s comment for updated information (Thank you)

Tags: Programming · quick & easy tips · Web Design

4 responses so far ↓

  • 1 etestcids // Oct 21, 2008 at 3:16 am

    Hi,
    I am, John
    good overall content
    my site:

    http://pX1qGcT4u.spaces.live.com/

  • 2 RaiulBaztepo // Mar 29, 2009 at 12:14 am

    Hello!
    Very Interesting post! Thank you for such interesting resource!
    PS: Sorry for my bad english, I’v just started to learn this language ;)
    See you!
    Your, Raiul Baztepo

  • 3 Mike Schinkel // Apr 12, 2010 at 7:24 am

    Hi Alex,

    Conceptually, this is a great idea. In practice, you are suggesting that someone modify WordPress’ core code which isa really bad idea. Instead, they should use a filter “hook.” They can add this to their theme’s functions.php file to do the same:

    add_filter(‘excerpt_length’,'set_my_excerpt_length’);
    function set_my_excerpt_length($length) {
    return 100;
    }

    This works for WordPress v2.7 and later, see:
    http://adambrown.info/p/wp_hooks/hook/excerpt_length?version=2.7&file=wp-includes/formatting.php

    HTH.

    -Mike

  • 4 Alex Costa // Apr 12, 2010 at 12:56 pm

    Hi Mike

    Thank you for the comment and improvement on the content of this post. I have added a link to your comment in the main post body.

Leave a Comment