Shortcodes in excerpts not working

I am trying to use shortcodes in an excerpt. I notice that in the theme(not one of wpmudev) I am using the function add_filter('the_excerpt', 'do_shortcode'); is in there, but shortcodes are still not working. Are you aware of any reason it still might not work?
I have eclipse set up and I was going to step through the code to see if I could figure out why it is not working. Can someone suggest a good place to toggle a breakpoint? Or maybe a function to take a look at?

  • Adam Czajczyk

    Hello Charlotte,

    I hope you're well today and thank you for your question!

    By default shorcodes are not executed in excerpts. The

    add_filter('the_excerpt', 'do_shortcode');

    function should help here but very often themes do not relay on "the_excerpt()" template function to show excerpts on your site. Sometimes custom code relies on native "get_the_excerpt()" function and its output is then processed but also often completely different solutions are used.

    That said, I'd try first replacing

    add_filter('the_excerpt', 'do_shortcode');

    in your theme's function.php file with following lines:

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

    Let me know please if it helped, please!

    Best regards,

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.