Beginner's Guide for WordPress - Start your WordPress Blog in minutes.
Choosing the Best
WordPress Hosting
How to Easily
Install WordPress
WordPress Plugins
View all Guides

How to Use Shortcodes in your WordPress Sidebar Widgets

Last updated on by
Special WordPress Hosting offer for WPBeginner Readers
How to Use Shortcodes in your WordPress Sidebar Widgets

We showed you how to add a shortcode in WordPress, then we also showed you how you can use shortcodes in your WordPress Themes. In this article, we will show you how to use shortcodes in your WordPress sidebar.

First thing you need to do is open your theme’s functions.php file and paste this code:

add_filter('widget_text', 'do_shortcode');

Now all you have to do is go to your Appearance » Widgets Screen and create a text widget. Then you can paste any shortcode that you have enabled on your site, and it will function properly.

Editorial Staff at WPBeginner is a team of WordPress experts led by Syed Balkhi. Page maintained by Syed Balkhi.

WPBeginner's Video Icon
Our HD-Quality tutorial videos for WordPress Beginners will teach you how to use WordPress to create and manage your own website in about an hour. Get started now »


  1. Monuruzzaman Milon says:

    Really Awesome I love your all blog post. Because I’m learning about wordpress theme development .Really it’s help for me about add_filter hook.


  2. Alfredo says:

    Thank you so much.

  3. Arra Referees says:

    Thank You for this. Life Saver. Was using a plugin (GCAL) with a special sidebar widget but wouldn’t allow me to add a link to the calendar beneath it without delving into code. Simply adding this and using the short code really did the business. Many Thanks. Working in 4.1.1

  4. Manuel Meurer says:

    Awesome tip, still works great in WordPress 4.0!

  5. cob-web says:

    This saved my day – thanks! :)

  6. slim shady says:

    will it interpret [ ]everything as a shortcode?

    • WPBeginner Support says:

      No only if a shortcode is registered. For example if you dont have a shortcode [apples] then it will display as it is.

  7. queenofthehivemomof5 says:

    I tried putting it at the bottom of the fuctions PHP template within the php tags and am still getting the RAW code wrapped around my shortcode. The shortcode is displaying it just shows [raw] [/raw] on either side of it.

    Any other suggestions? Thanks in advance!

  8. wpbeginner says:

    @queenofthehivemomof5 You need to paste it in between the php tags and make sure it is not part of any other funciton… so it is best to place it at the bottom.

  9. queenofthehivemomof5 says:

    Is there a certain part of the fuctions.php file I should paste it into? It does not appear to be working for me. I get my shortcode output but it is surrounded by “Raw”

    [raw][/raw]TAB 1TAB 2TAB 3[raw][/raw]Tab content 1[raw] [raw] [raw][/raw] (something like that)

  10. edward.caissie says:

    This line of code can be added to a plugin that has a shortcode and it will do the same thing, too … although adding the line of code to the functions.php file of a Child-Theme would be a more future-proof method.

Add a Comment

We're glad you have chosen to leave a comment. Please keep in mind that all comments are moderated according to our comment policy, and all links are nofollow. Do NOT use keywords in the name field. Let's have a personal and meaningful conversation.