Snippet: Enable Shortcodes In Widgets and Post Titles

Shortcodes are one of the most popular feature of the WordPress. It allows you to trigger a function within the post contents. We posted number of shortcodes you can use. Couple of builtin shortcodes are [gallery] and [embed].  Unfortunately, shortcodes does not work in text widget where we often like to use them. To enable it, you just need to paste following snippet in your functions.php

Snippet

// Execute shortcodes in widget's text
add_filter('widget_text', 'do_shortcode');

// Execute shortcodes in post and meta title.
add_filter('the_title', 'do_shortcode');
add_filter('wp_title', 'do_shortcode');

Leave a Reply

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

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>