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.
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
- Method 2: Adding Shortcode in WordPress Sidebar Using Text Widget
- Method 3: Adding Shortcode in WordPress Sidebar Using Custom HTML Widget
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.
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.
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.
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.
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.
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.’
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.
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:
And this is what it looks like using the classic widget editor:
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.
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.
Arkanum says
Thanks! For me it’s work
WPBeginner Support says
Glad our guide helped
Admin
Zdenko Zec says
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
WPBeginner Support says
You may want to ensure the shortcode you’re using is a working shortcode.
Admin
Thanks a lot!! says
Great post! thank you very much
WPBeginner Support says
You’re welcome
Admin
Muhammad Zeeshan says
Hi
Good morning
Actually i want to show only text of the post on a specific page,how can i do this?
WPBeginner Support says
For what it sounds like you’re wanting, you may want to take a look at:
https://www.wpbeginner.com/plugins/how-to-insert-wordpress-page-content-to-another-page-or-post/
Admin
Rahul says
Last night i have install an Plugin for shortcode. But i could not use it. But now i’m success
WPBeginner Support says
Glad our article could help
Admin
Ahmer says
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.
MikeL says
The custom code option only works in the widget text CONTENT area, but not the TITLE area.
nicole says
where do you go to actually create the shortcodes?? Im looking for where to find the settings shown in this screenshot:
Neville says
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
Brendan says
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
lukman says
It.is.not.working
Mathiew Burkett says
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.
Gurpreet Singh Saini says
Thanks its working.
Bilal says
yes, its working.
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
WPBeginner Support says
Please report the conflict to plugin author.
Admin
Vinicius says
Thanks!
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.
Thanks,
Alfredo says
Thank you so much.
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
Manuel Meurer says
Awesome tip, still works great in WordPress 4.0!
cob-web says
This saved my day – thanks!
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.
Admin
firoz says
I want to shortcode in the sidebar
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!
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.
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)
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.