Using WordPress shortcode in a title

I have some shortcodes which work fine inside a WordPress post or page. Is there anything I can add to functions.php to enable a shortcode to work inside a WordPress post title?

Related posts

Leave a Reply

2 comments

  1. Add the following filter to functions.php as mentioned by David

    add_filter( 'the_title', 'do_shortcode' );
    

    However, this approach may not work if you are using the Yoast SEO plugin. For that, you need to add the following filter too:

    add_filter( 'wpseo_title', 'do_shortcode' );