Enable Shortcodes In Widgets
WordPress 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.
Now you can use these in widgets the same way you would in your posts.
Learn how to code with Treehouse
- Learn projects with access to 1000+ videos
- Practice live with our Code Challenge Engine
- Get help in our members-only forums
Join the weekly newsletter
Sign up for our newsletter. You'll be updated on new tutorials as they come available.
Subscribe today and get a 50% discount code to Paulund