
You know it, I love shortcodes, and wrote about time some days ago. But a very frustrating thing is that you can’t add shortcode in sidebar Widgets. You can’t? yes, unless you read that recipe!

You know it, I love shortcodes, and wrote about time some days ago. But a very frustrating thing is that you can’t add shortcode in sidebar Widgets. You can’t? yes, unless you read that recipe!
To allow shortcodes in sidebar widgets, simply edit the functions.php file from your them and add the following code:
add_filter('widget_text', 'do_shortcode');
Once you saved the file, you can now add as many shortcodes as you want in sidebar widgets.
Credits goes to English Mike for this awesome recipe!
12 Responses
Works for the most part, although with a shortcode that generates CSS dynamically, it neglects to generate the necessary CSS.
It’s funny because I was able to add shortcodes to my wordpress (3.3.1) no problem. Then I did a search and found this post, did exactly as instruction and now it works….My question is, why would it stop working after it worked for so long?
weird….
Thanks though!
Excellent – thanks for this. Used it to get Soundcloud working in a sidebar widget.
Thank you! (:
Thanks it worked!
Thanks Dude.
Superb. I really want this Functionality (Shortcode) in Widget.
Thanks.
I tried this and it put the shortcode for my contact form in the sidebar, but the shortcode then the contact form ceased working when I used the shortcode in the widget sidebar. The form works OK on the page, but not when I make the above change & then put my contact form in the widget sidebar, using its shortcode.
Just wondering if anyone else has had problems with shortcodes/plugins ceasing to work properly when they employ the above tactic to put the same shortcode in the widget sidebar?
I cannot for the life of me get this to work!?
Adding this into functions file
Causes my whole sidebar to not display at all? I’m using the Bones Theme on WordPress 3.3.2
Anyone had similar issues?
Working fine, Thanks a lot…..
Your solution is brilliant!!! Just added testimonial submission form to sidebar on testimonials page for client project! thanks for the simple and easy solution!!
All the best-
Markus
Didn’t work for me, but not sure I placed the code in the right place. Here is where I placed it in my functions.php file from my theme.
/**
* Register widgets.
*/
function ifp_widgets_init() {
register_sidebar(array(
‘name’ => ‘Full Sidebar’,
‘id’ => ‘sidebar-widgets’,
‘description’ => ‘These are widgets for the sidebar.’,
‘before_widget’ => ”,
‘after_widget’ => ”,
‘before_title’ => ”,
‘after_title’ => ”
));
register_sidebar(array(
‘name’ => ‘Left Half Sidebar’,
‘id’ => ‘sidebar-left’,
‘description’ => ‘These are widgets for the left sidebar.’,
‘before_widget’ => ”,
‘after_widget’ => ”,
‘before_title’ => ”,
‘after_title’ => ”
));
register_sidebar(array(
‘name’ => ‘Right Half Sidebar’,
‘id’ => ‘sidebar-right’,
‘description’ => ‘These are widgets for the right sidebar.’,
‘before_widget’ => ”,
‘after_widget’ => ”,
‘before_title’ => ”,
‘after_title’ => ”
));
register_sidebar(array(
‘name’ => ‘Box 1′,
‘id’ => ‘box-1′,
‘description’ => ‘This is the first widget of the four-box section’,
‘before_widget’ => ”,
‘after_widget’ => ”,
‘before_title’ => ”,
‘after_title’ => ”,
));
register_sidebar(array(
‘name’ => ‘Box 2′,
‘id’ => ‘box-2′,
‘description’ => ‘This is the second widget of the four-box section’,
‘before_widget’ => ”,
‘after_widget’ => ”,
‘before_title’ => ”,
‘after_title’ => ”,
));
register_sidebar(array(
‘name’ => ‘Box 3′,
‘id’ => ‘box-3′,
‘description’ => ‘This is the third widget of the four-box section’,
‘before_widget’ => ”,
‘after_widget’ => ”,
‘before_title’ => ”,
‘after_title’ => ”,
));
register_sidebar(array(
‘name’ => ‘Box 4′,
‘id’ => ‘box-4′,
‘description’ => ‘This is the fourth widget of the four-box section’,
‘before_widget’ => ”,
‘after_widget’ => ”,
‘before_title’ => ”,
‘after_title’ => ”,
));
register_sidebar(array(
‘name’ => ‘Footer’,
‘id’ => ‘footer-widgets’,
‘description’ => ‘These are the footer widgets’,
‘before_widget’ => ”,
‘after_widget’ => ”,
‘before_title’ => ”,
‘after_title’ => ”,
));
}
add_action (‘widgets_init’, ‘ifp_widgets_init’);
add_filter(‘widget_text’, ‘do_shortcode’);
Trackbacks: