Beginner's Guide for WordPress / Start your WordPress Blog in minutes

How to Use Shortcodes in your WordPress Sidebar Widgets

Do you want to learn how to use shortcodes in the sidebar widgets of your WordPress website?

Shortcodes allow you to add additional features to your WordPress post content and other areas of your website. Because shortcodes are such a basic part of WordPress, it’s odd that some sidebar widgets do not automatically render shortcodes.

In this article, we will show you how to use shortcodes in your WordPress sidebar widgets.

How to Use Shortcodes in Your WordPress Sidebar Widgets

What Are Shortcodes?

Shortcodes allow you to add dynamic items like contact forms, tables, and others inside your WordPress content area.

You can also use shortcodes in some widgets to add these dynamic items to your sidebars and other widget-ready areas. You can learn more by reading our 7 essential tips for using shortcodes in WordPress.

Let’s take a look at how to easily add and use shortcodes in the sidebar widgets on your WordPress website. We’ll cover three methods, and the first method is the simplest for most users.

Method 1: Adding Shortcode in WordPress Sidebar Using Shortcode Widget

First, you need to visit the Appearance » Widgets screen in your dashboard. Once there, you should click the + icon at the top of the screen to add a new widget.

Next, you should scroll down to the Shortcode widget and drag it onto the WordPress sidebar.

Add a Shortcode Widget

After adding the widget, you can simply add your shortcode inside the text edit area of the widget.

Don’t forget to click on the ‘Update’ button to store your widget settings.

You can now visit your website and see the shortcode in action.

Shortcode Displayed in Sidebar Widget

If your theme uses full-site editing, the process will be a little different.

You will go to Appearance » Editor in your dashboard to access the site editor.

Full site editor is under Appearance then Editor.

When that opens, you just need to go to a page on your blog that has the sidebar you want to add the widget to.

Just click the ‘+’ button at the top, search for ‘shortcode,’ and add the widget the same as above.

Because of the way full-site editing works, you are no longer limited to only using widgets in sidebars. If your theme supports it, you can add a shortcode block to any widget-enabled area, which includes header menus and more.

Method 2: Adding Shortcode in WordPress Sidebar Using Text Widget

If you use an older version of WordPress or have installed the Classic Widgets plugin to disable the block editor from managing widgets, then you’ll have to use a ‘Text’ instead of a ‘Shortcode’ widget.

First, you need to visit the Appearance » Widgets screen in your dashboard. Next, you should drag and drop a ‘Text’ widget to your WordPress sidebar.

Adding Shortcode in Text Widget

After adding the widget, you can simply add your shortcode inside the text edit area of the widget.

Don’t forget to click on the ‘Save’ button to store your widget settings.

You can now visit your website to see your shortcode in action.

Shortcode Added by Custom HTML Widget

Method 3: Adding Shortcode in WordPress Sidebar Using Custom HTML Widget

Sometimes you may want to add custom HTML code around your shortcode, and that doesn’t work well with a ‘shortcode’ block or ‘text’ widget. In that case, you will need to add your shortcode using the ‘Custom HTML’ block.

Unfortunately, shortcodes are not allowed in a ‘Custom HTML’ widget. To change this, you will need to add custom code to your theme’s functions.php directly or by using the free WPCode plugin (recommended).

To begin, you will need to install and activate WPCode. For more information, you can see our step-by-step guide on how to install a WordPress plugin.

First, navigate to Code Snippets » Add Snippet in your WordPress admin dashboard. Search for ‘shortcode’ and hover over the result called ‘Enable Shortcode Execution in Text Widgets.’

You can then click on ‘Use snippet.’

Seach for shortcode and then click Use Snippet

After this, you will be taken to the ‘Edit Snippet’ page. WPCode configures all the snippet settings for you.

All you need to do is click on the switch to toggle it to ‘Active’ and then press the ‘Update’ button.

Add snippet to enable shortcode execution in widgets with WPCode

After that, you can simply add a ‘Custom HTML’ widget to your sidebar and add your shortcode inside it.

Here’s how it looks in the block editor:

Add a Custom HTML Widget

And this is what it looks like using the classic widget editor:

Adding shortcode inside Custom HTML widget in WordPress

Don’t forget to click on the ‘Update’ or ‘Save’ button to store your changes to the widgets.

You can now visit your website to see your shortcode in action.

Shortcode Added by Custom HTML Widget

We hope this article helped you learn how to easily add shortcodes to your WordPress sidebar widgets. You may also be interested in our 7 essential tips for using shortcodes or our guide on how to find and remove unused shortcodes on your WordPress site.

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.

Disclosure: Our content is reader-supported. This means if you click on some of our links, then we may earn a commission. See how WPBeginner is funded, why it matters, and how you can support us.

The Ultimate WordPress Toolkit

Get FREE access to our toolkit – a collection of WordPress related products and resources that every professional should have!

Reader Interactions

34 CommentsLeave a Reply

  1. Hi there. I have tried it on my website developed localhost but it is not working. I have tried both with the text widget and by adding the filter to the functions.php and using the Custome HTML. Can you please share your thoughts about that? Cheers

  2. Hi
    Good morning
    Actually i want to show only text of the post on a specific page,how can i do this?

  3. This is very good and informative post about how to use shortcodes.

    I was looking for such article.

    Shortcodes really make difference in blogs and many people don’t know how to use them properly.

  4. where do you go to actually create the shortcodes?? Im looking for where to find the settings shown in this screenshot:

  5. Hi there,

    I have experience in website development, but am new to WooCommerce. I am building a website for a client, based on the Avada WP theme (5.6.1). This is under development:

    You will see that there is a carousel on the Home page, but I have been looking without success for a plugin to replace this which will allow me to display variable products in gallery/grid style. Needs to work with Woocommerce product variations, e.g. price, category, brief description. Add to Cart also would be ideal.

    I am wondering if shortcodes could be used to create this?

    If so, how could they be added to replace the carousel?



  6. Hi,

    I tried using the shortcode widget as you suggested but I am still unable to align the widgets at the footer side by side rather than on top of each other.

    Are you able to help please?

    Thank you!


  7. Hello

    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.

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

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


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

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

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

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

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

Leave A Reply

Thanks for choosing to leave a comment. Please keep in mind that all comments are moderated according to our comment policy, and your email address will NOT be published. Please Do NOT use keywords in the name field. Let's have a personal and meaningful conversation.