• Resolved Ben Kaminski

    (@tzhben)


    I am currently using this plugin on a WPMU build and it works great. I have had one complaint from someone on my network that any [lead] text is ignored by the default <?php the_excerpt(); ?> and does not show up in search or tag pages, news lists that show the excerpt.

    How to add the lead text into the excerpt?

    Thanks!

Viewing 1 replies (of 1 total)
  • Thread Starter Ben Kaminski

    (@tzhben)

    RESOLVED!!! Anyone else experiencing this problem should paste the following in their functions.php file:

    add_filter('the_excerpt', 'do_shortcode');
    remove_filter('get_the_excerpt', 'wp_trim_excerpt', 10);
    add_filter('get_the_excerpt', 'my_custom_wp_trim_excerpt', 99, 1);
    function my_custom_wp_trim_excerpt($text) {
        if(''==$text) {
            $text= preg_replace('/\s/', ' ', wp_strip_all_tags(get_the_content('')));
            $text= explode(' ', $text, 56);
            array_pop($text);
            $text= implode(' ', $text);
        }
        return $text;
    }

    This will maintain the font size of the lead text in the excerpt but can easily be modified via CSS now that it’s visible.

    • This reply was modified 8 years, 3 months ago by Ben Kaminski.
Viewing 1 replies (of 1 total)
  • The topic ‘Lead Text Ignored by Post Excerpt’ is closed to new replies.