Enabling shortcodes in widgets

Shortcodes make life easier for a blogger. I can easily list subpages, add post meta elements and even query posts using shortcodes. You can do as much in your widgets too, you just need a quick fix to enable shortcodes in your widgets.

To enable shortcode functions in your widgets you can use the code below:

add_filter('widget_text', 'do_shortcode');

Add this code to functions.php in your theme folder. This way you can easily use your theme/plugin based shortcodes on your sidebar. For example if you are using my adsense widget, you could easily add a square ad to your sidebar using:

[adsense type="small-square"]

Or you could list subpages of a page using:

[subpages exceptme="true" childof="253"]

Related Posts

NS Weight Release

WP-Backgrounds Lite by InoPlugs Web Design and Juwelier Schönmann 1010 Wien