DISCLAIMER: this post is older than one year and may not be up to date with latest WordPress version.

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!

17 Comments

  1. Works for the most part, although with a shortcode that generates CSS dynamically, it neglects to generate the necessary CSS.

  2. 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!

  3. Excellent – thanks for this. Used it to get Soundcloud working in a sidebar widget.

  4. Thank you! (:

  5. Thanks it worked!

  6. Superb. I really want this Functionality (Shortcode) in Widget.
    Thanks.

  7. 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?

  8. 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?

  9. Working fine, Thanks a lot…..

  10. 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

  11. 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’);

  12. Works! Ended my sidebar frustrations, thanks very much.

  13. Worked an absolute treat. Thanks so much.

  14. Simple tricked. But worked for me. Thanks!

  15. where do i place the syntax.. the function.php file has many functions, which function to i place it in???…

    Thanks…

  16. Thank you! Worked great for me

Leave a Comment

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