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

In the past, we have shown you how to add and use widgets in WordPress. One of the most asked questions we get about widgets is how can I add shortcodes in WordPress sidebar widgets? By default, shortcodes does not work in sidebar widgets. In this article, we will show you how to easily use shortcodes in your WordPress sidebar widgets.

Using shortcodes in WordPress sidebar widgets

Why Shortcodes Doesn’t Work in WordPress Widgets?

In WordPress, shortcodes provide an easier way to add functionality in text areas like post editor when you are writing a post.

Often beginners think that because there’s a text widget in your sidebar, shortcodes will automatically work. By default, any text entered into the text widget goes through WordPress filters which doesn’t allow shortcodes to be executed.

Shortcode not executed in sidebar text widget in WordPress

Instead of seeing the final result, you will see the shortcode itself as plain text.

It is very easy to change that, and we will show you how to easily enable shortcodes to be executed in WordPress text widgets.

Method 1: Adding Shortcode Enabled Text Widget in WordPress

In this method, we will be using a simple WordPress plugin. This method is recommended for beginners who don’t want to add code manually.

First thing you need to do is install and activate the Shortcode Widget plugin. For more details, see our step by step guide on how to install a WordPress plugin.

Upon activation, you need to visit Appearance » Widgets page. There you will find a shortcode widget in the list of available widgets.

Simply add the shortcode widget to a sidebar and then add your shortcode in the content box. Don’t forget to click on the save button to store your widget settings.

shortcode widget

This shortcode widget is just like the default text widget in WordPress. The only difference is that you can add shortcodes inside it.

Method 2: Enabling Shortcodes in WordPress Text Widget

If you are comfortable adding code to your theme, then you can enable shortcodes to work in text widgets.

Simply add this code to your theme’s functions.php file or a site-specific plugin.

// Enable shortcodes in text widgets

This code simply adds a new filter allowing shortcodes to run inside text widget.

You can now visit Appearance » Widgets page and add a text widget to a sidebar. Paste the shortcode in the content box and click on the save button.

Visit your website to see shortcode working inside text widgets.

Shortcode working in WordPress widget

We hope this article helped you learn how to use shortcodes in your WordPress sidebar widgets. You may also want to see our list of 7 essential tips for using shortcodes in WordPress.

If you liked this article, then please subscribe to our YouTube Channel for WordPress video tutorials. You can also find us on Twitter and Facebook.

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. Mathiew Burkett says:


    I have created the Site Specific Plugin and activated the plugin.

    I am trying to get a shortcode to work in a different area where a shortcode will not currently work with my Theme.

    I am using the Socrates 3.08 version theme.

    Here is a link to a screenshot that I created that shows the two places that I have circled with a red circle where I need a shortcode to work and I right clicked on the area where I need to add the plugin and inspected it to find the code in the area of my theme where I am trying to get a shortcode to work at and added the screenshot of the code also.

    Would someone tell me if there is a function that I could add to the site specific plugin that will get a shortcode to work in the two areas that I have circled.

  2. Gurpreet Singh Saini says:

    Thanks its working.

  3. Bilal says:

    yes, its working.

  4. A WP Life says:

    Hi There,

    User reported after new WordPress update 4.5.3.

    Shortcode not working in text widget..

    Our plugin is

    Need help, thanks in advance.

    A WP Life

  5. Vinicius says:


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


  7. Alfredo says:

    Thank you so much.

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

  9. Manuel Meurer says:

    Awesome tip, still works great in WordPress 4.0!

  10. cob-web says:

    This saved my day – thanks! :)

  11. slim shady says:

    will it interpret [ ]everything as a shortcode?

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

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

  14. 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)

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