in WordPress

Enable Shortcodes In Widgets

WordpressWordpress shortcodes are great, they allow you to run bits of PHP code from within the text editor by using tags like [ button ] to display a button1. But there is a problem with shortcodes and you can't run them from within widgets by default. This isn't too much of a problem if you haven't wrote the widget. But for you Wordpress developers that want to use one of your shortcodes in Widgets you need to add the following snippet in your functions.php file.


add_filter('widget_text', 'do_shortcode');

Now you can use these in widgets the same way you would in your posts.

Upgrade to access all content on Paulund

Members unlock all tutorials and snippets

Access to all downloadable content

Access to code examples before others

Sign Up Now

Already a member? Login here

Subscribe To The Weekly Newsletter

Get weekly updates to your email