WordPress Tip: How To Use Shortcodes in Widgets

WordPress Tip: How To Use Shortcodes in Widgets featured image
(Last Updated On: December 13, 2017)

Shortcodes are great, and can be used for a variety of purposes within WordPress to cut out the hassle of adding code all over the place.

Even better, shortcodes allow you to edit things centrally and have them updated wherever they appear across your blog.

But, often, we find, our clients would like a feature in a sidebar, header, or footer widget which would be best driven by a shortcode.

WordPress doesn’t let you put shortcodes into widgets out of the box. But, with one simple modification, you can get this working on your WordPress website!

The fix is as follows:

  1. login to WordPress
  2. Under Appearence > Editor, visit the functions.php page of your current active theme
  3. Add the following code to the bottom of that file:

add_filter('widget_text', 'do_shortcode');

NOTE: This should be added before the closing ?>

Next, hit “Update” and then add a text widget with a shortcode in it to see how this performs.

Any problems, leave a comment below for us to solve publicly, and help out the community of people who also face the same issue!

If you can’t manage the above work, feel free to contact us about having Silicon Dales manage your WordPress website on your behalf.

Leave a Reply

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

Silicon Dales