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 do add additional features in your WordPress post content and other areas of your website.

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 form, tables, and others inside your WordPress content area.

You can also use shortcodes in your widgets to add these dynamic items in 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

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 widget 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 which may not work so well in a shortcode or plain text widget. In that case, you will need to add your shortcode using the Custom HTML widget.

By default, shortcodes are not allowed to be executed in a custom HTML widget. To change this, you will need to add the following code to your theme’s functions.php file or a site-specific plugin.

add_filter( 'widget_text', 'do_shortcode' );

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 new block-based widgets 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 settings.

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 want to learn how to move your WordPress site from HTTP to HTTPS, or check out our list of must have plugins to grow your 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?

    Thanks.

    Neville

  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!

    Brendan

  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.

    Thanks,

  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.