0

I am developing a plugin that uses shortcodes. I wanted to enable users to use shortcodes in excerpts, so I added the line

add_filter('the_excerpt', 'do_shortcode');

which worked fine.However, in my RSS feed, the excerpt is still a shortcode. I tried all of the following:

add_filter('get_the_excerpt', 'do_shortcode');
add_filter('the_excerpt_rss', 'do_shortcode');
add_filter('the_content_rss', 'do_shortcode');

But it does not work still. Can someone point me to the right filter so the excerpt would be processed correctly in the feed as well?

Please note that those are manually edited excerpts, not automatically generated ones.

3
  • 1
    add_filter('the_excerpt_rss', 'do_shortcode'); should work fine because I just tried and it did. I think there is some issue in your shortcode handler function. So please update your question to include that code. If possible please share the link of site where you are testing this plugin to see the /feed it in action. Commented May 6, 2016 at 8:13
  • Well wouldn't you know it, I tried the above code that you had there and it worked. Problem solved, I guess :) No idea why it did not work before.
    – uncovery
    Commented May 6, 2016 at 11:46
  • @ItsMePN as an answer please. :)
    – Rarst
    Commented May 6, 2016 at 15:56

1 Answer 1

2

I tested following code and it worked just fine for me:

function my_name_shortcode( $atts ) {
    return "<h3>PRASAD</h3>";
}
add_shortcode( 'name', 'my_name_shortcode' );

add_filter( "the_excerpt_rss", "do_shortcode" );

The result can be seen in below screenshot.

enter image description here

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.