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.