WordPress.org

Ready to get started?Download WordPress

Forums

Show shortcodes in excerpt (5 posts)

  1. object81
    Member
    Posted 3 years ago #

    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.

  2. cubecolour
    ɹoʇɐɹǝpoɯ
    Posted 3 years ago #

    This in your functions.php should do it:

    add_filter( 'the_excerpt', 'shortcode_unautop');
    add_filter( 'the_excerpt', 'do_shortcode');
  3. object81
    Member
    Posted 3 years ago #

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

  4. rlgrobert
    Member
    Posted 3 years ago #

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

  5. rlgrobert
    Member
    Posted 3 years ago #

    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?

Topic Closed

This topic has been closed to new replies.

About this Topic