0

So I have been doing some digging and narrowed down the file that I believe is calling for the front page excerpts on all posts. No matter what I change it to, it doesn't seem to adjust.

//get excerpt for feed panels
function con_feed_excerpt() {
$excerpt = get_the_excerpt();       
if (strlen($excerpt)>230) {
    $excerpt = substr($excerpt, 0, 227) . "...";
}
echo $excerpt;
}

This looks to be where it is getting the excerpt length from the first character to the 227th char and then ending with a ...

I've tried changing the 227 and re-uploading to my server and to no avail.

Any clues what might be preventing it?

3
  • 2
    Are you certain that's the right function because seems to be for the RSS feed or something to do with RSS/Feed. Which file is that in? Which file is controlling your front page? Is it an index.php file or is it another file being called into index.php or are you being redirected to another file from index.php. The likely culprit lay within that file whichever it may be. Need more info...
    – Adam
    Apr 26, 2012 at 0:57
  • 1
    Also: Please always provide a link
    – kaiser
    Apr 26, 2012 at 1:30
  • Please, provide a link! And, there are some caches enabled in the site?
    – keatch
    May 3, 2012 at 12:36

2 Answers 2

1

Here is a custom function I've written to modify your excerpt however you want. You should NOT be changing any core files to make modifications, as these will be overwritten by any updates made to the Wordpress framework:

remove_filter('get_the_excerpt', 'wp_trim_excerpt');
add_filter('get_the_excerpt', 'preserve_excerpt_format');
function preserve_excerpt_format($text)
{
    global $post;
    $raw_excerpt = $text;
    if ('' == $text )
    {
        $text = get_the_content('');
        $text = strip_shortcodes($text);
        $text = apply_filters('the_content', $text);
        $text = str_replace(']]>', ']]>', $text);

        $exceptions = '<p>,<a>,<em>,<strong>,<br>'; //PRESERVE THESE TAGS, ADD/REMOVE AS NEEDED
        $text = strip_tags($text, $exceptions);

        $maxCount = 55; //DEFAULT WP WORD COUNT, INCREASE AS NEEDED
        $excerpt_length = apply_filters('excerpt_length', $maxCount);

        $moreText = '.... <a class="blue" href="'.get_permalink($post->ID).'">Read More &gt;&gt;</a>'; //CUSTOM MORE TEXT, CHANGE AS NEEDED
        $excerpt_more = apply_filters('excerpt_more', $moreText);

        $words = preg_split("/[\n\r\t ]+/", $text, $excerpt_length+1, PREG_SPLIT_NO_EMPTY);
        if(count($words) > $excerpt_length)
        {
            array_pop($words);
            $text = implode(' ', $words);
            $text = $text.$excerpt_more;
        }
        else
            $text = implode(' ', $words);
    }
    return apply_filters('wp_trim_excerpt', $text, $raw_excerpt);
}

Place this in the functions.php file of your current theme, and change as needed.

0

I did seem to get it working with a custom plugin. There doesn't seem to be an option for adjusting the front of site feed versus the category feeds. I found out later that modifying the 227 figure to say 800 just lengthened the excerpt for the individual feed and not for the front page posts.

All is well with an excerpt plugin though, lets me set both which is exactly what I wanted.

1
  • which plugin did you use to solve this? I have the same problem here
    – user18615
    Jul 27, 2012 at 5:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.