Support » Themes and Templates » Show shortcodes in excerpt

  • I want to show shortcodes in my excerpt. By default WP strips out all shortcodes, but then my experpt text is often incomplete.

    I use the Wikipop Plugin to generate hyperlinks to Wikipedia. Like when the post starts with: This article is all about [wikipop]Bill Gates[/wikipop], the founder of Microsoft..., WP doesn’t just strip out the shortcode tags, but also whats between them. In this case the name Bill Gates. The excerpt then looks like: This article is all about , the founder of Microsoft...

    I have tried all kinds of suggestions, but nothing seems to work here. I use a Child Theme of TwentyTen and have added the following to my functions.php:

    add_filter( 'the_excerpt', 'do_shortcode');
    	add_filter( 'get_the_excerpt', 'do_shortcode', 5 );

    I also tried the following within the loop:
    <?php echo do_shortcode(get_the_excerpt()); ?>

    I’m stuck here, appreciate ANY help.

Viewing 4 replies - 1 through 4 (of 4 total)
  • Moderator cubecolour

    (@numeeja)

    ɹoʇɐɹǝpoɯ

    This in your functions.php should do it:

    add_filter( 'the_excerpt', 'shortcode_unautop');
    add_filter( 'the_excerpt', 'do_shortcode');

    Thanks for your advice. But that doesn’t work for me.

    Those two lines aren’t working for me either. Any ideas? I’m on WP3.0.5.

    Clarification: The two lines of code work fine for me when an excerpt is manually entered for a post. However, if I have not entered a separate excerpt, the_excerpt() pulls the first few lines of text from the content, and in this case the shortcodes are not executed.

    Is there a way for these filters to be applied to the_excerpt() on posts where the excerpt text is automatically generated?

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Show shortcodes in excerpt’ is closed to new replies.