Helping you Build Your Own Social Network!

Faster, better and easier!

limit the_excerpt()

(3 posts) (3 voices)

Tags:

No tags yet.


  1. I found the code to shorten the excerpt displayed in the featured post widget for my active theme. Looking at the plugin, it's pulling the_excerpt() but the problem is that with a long excerpt, it overflows and breaks the divs so sometimes it overflows the div underneath it.

    I've added this to my functions.php of my child theme:

    function new_excerpt_length($length) {
    return 10;
    }
    add_filter('excerpt_length', 'new_excerpt_length');

    This is SUPPOSED to be the filter to limit the excerpt length within wordpress so I don't have to actually modify the plugin that's calling that for the home page.

    When I upload that to my child theme and refresh the page, it's not taking effect and still allowing all of the_excerpt to display. Any idea why that's not taking effect? I've checked the parent theme's functions to make sure it didn't have the same type of filter but found nothing.

    Thanks.

    Posted 1 year ago #
  2. hi Chris, try to lower the priority of your function, sometimes, it may not be working because some other plugin may be overwriting it.

    try something like this

    add_filter('excerpt_length', 'new_excerpt_length',200);

    Is it working ?

    Posted 1 year ago #
  3. Hi Chris -
    Check this out http://www.aaronrussell.co.uk/blog/improving-wordpress-the_excerpt/
    If you're using WPMU copy from line 1802 - 1822 http://trac.mu.wordpress.org/browser/tags/2.9.2/wp-includes/formatting.php and change accordingly
    If WP 3.0 trunk copy from line 1823 - 1845 http://core.trac.wordpress.org/browser/trunk/wp-includes/formatting.php and change accordingly

    There might be simpler ways to do this, but the above has worked for me :-)

    EDIT - didn't see your post earlier, Brajesh, took too much time to answer. Will try your method too :-)

    Posted 1 year ago #

Reply

You must log in to post.