Do you want to learn how to use shortcodes in your WordPress sidebar widgets? 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.
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 area.
Let’s take a look at how to easily add and use shortcodes in your WordPress sidebar widgets.
Method 1: Adding Shortcode in WordPress Sidebar Using Text Widget
First thing you need to do is drag & drop a Text widget to your WordPress sidebar on the Appearance » Widgets screen in your dashboard. 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 and see the shortcode in action.
Method 2: Adding Shortcode in WordPress Using Custom HTML Widget
Sometimes you may want to add custom HTML code around your shortcode which may not work so well in the 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.
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.
We hope this article helped you learn how to easily add shortcode to your WordPress sidebar widgets. You may also want to see these 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.
Thanks! For me it’s work
Glad our guide helped
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
You may want to ensure the shortcode you’re using is a working shortcode.
Great post! thank you very much
You’re welcome
Hi
Good morning
Actually i want to show only text of the post on a specific page,how can i do this?
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/
Last night i have install an Plugin for shortcode. But i could not use it. But now i’m success
Glad our article could help
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.
The custom code option only works in the widget text CONTENT area, but not the TITLE area.
where do you go to actually create the shortcodes?? Im looking for where to find the settings shown in this screenshot:
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
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
It.is.not.working
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.
Thanks its working.
yes, its working.
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
Please report the conflict to plugin author.
Thanks!
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,
Thank you so much.
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
Awesome tip, still works great in WordPress 4.0!
This saved my day – thanks!
will it interpret [ ]everything as a shortcode?
No only if a shortcode is registered. For example if you dont have a shortcode [apples] then it will display as it is.
I want to shortcode in the sidebar
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!
@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.
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)
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.