Run Shortcode on Widget Title

To run shortcode inside widget title you could add a filter on widget_title

add_filter( 'widget_title', 'do_shortcode' )

Sample usage, example you add [b] shortcode inside widget title:

Make my title [b]bold[/b]

Here’s how we could add some filters in it:

function boldify( $atts, $content = "" ) {
    return "<strong>$content</strong>";
}
add_shortcode( 'b', 'boldify' );
add_filter( 'widget_title', 'do_shortcode' );

Output:

Make my title <strong>bold</strong>

Leave a Reply

Your email address will not be published. Required fields are marked *