WordPress shortcodes are small, one word keywords enclosed in [square brackets] that allow you to add functionality to WordPress. By default, you can use shortcodes in Posts and Pages, but not Widgets. Some users may want use a Widget that uses a shortcode to add a gallery or other macro into the sidebar. For more information on using Widgets, please see our WordPress Education Channel: Introduction to Plugins and Widgets.
First, we'll see the default WordPress behavior when we use the gallery shortcode in a Text Widget.
Here's what we see by default:
Well, that's not very exciting is it? The good news is that this is fairly easy to fix. You actually have two choices to enable shortcodes in widgets in WordPress:
Installing and enabling this plugin is the preferred method for adding this capability in WordPress. With this plugin, even if you change your theme in the future, shortcodes in your WordPress sidebar will still be enabled.
While the following method is not the recommended method, some people may want to know how to enable shortcodes in widgets by adding some code to their theme's functions.php.
The following method would need to be repeated for each theme if you decide to switch themes in the future. Before proceeding with the following instructions, you should first create a Child Theme for your preferred theme and activate the Child Theme.
<?php
add_filter( 'widget_text', 'shortcode_unautop');
add_filter('widget_text', 'do_shortcode');
?>
Email: | support@WebHostingHub.com | Ticket: | Submit a Support Ticket |
---|---|---|---|
Call: |
877-595-4HUB (4482) 757-416-6627 (Intl.) |
Chat: | Click To Chat Now |
We value your feedback!
There is a step or detail missing from the instructions.
The information is incorrect or out-of-date.
It does not resolve the question/problem I have.
new! - Enter your name and email address above and we will post your feedback in the comments on this page!