{"id":20506,"date":"2021-02-17T17:00:17","date_gmt":"2021-02-17T16:00:17","guid":{"rendered":"https:\/\/qodeinteractive.com\/magazine\/?p=20506"},"modified":"2021-12-22T13:08:08","modified_gmt":"2021-12-22T12:08:08","slug":"add-shortcode-to-wordpress-widget","status":"publish","type":"post","link":"https:\/\/qodeinteractive.com\/magazine\/add-shortcode-to-wordpress-widget\/","title":{"rendered":"How to Add Shortcodes to WordPress Sidebar Widgets"},"content":{"rendered":"<div class=\"wpb-content-wrapper\"><p>[vc_row][vc_column][vc_column_text]Shortcodes are <strong>a great way of adding new features and functionalities to your website<\/strong>. However, they have a limitation: they can be used only within the content of pages and posts. This is the case with default shortcodes as well as custom ones, those created by themes, plugins, or individual WordPress users. To work around this problem, some WordPress users have opted to edit the template files of their theme, plugins, or even WordPress core files. This would let them use shortcodes in other parts of their website, like the footer or the header. Apart from being error-prone, this method requires you to edit the same files again and again, as the changes will get overridden after each update.[\/vc_column_text][vc_empty_space height=&#8221;28px&#8221;][vc_column_text]Luckily, this is no longer needed. Now, <strong>you can insert a shortcode call into certain widgets and use them in any available widget areas<\/strong> (or WordPress sidebars, as some programmers call them). By doing so, you will be able to extend the functionality of a shortcode to any part of your website. However, as using shortcodes this way might not be common knowledge, we decided to explain it in this article.[\/vc_column_text][vc_empty_space height=&#8221;28px&#8221;][vc_column_text]For this article, <strong>we will be using two shortcodes which we created<\/strong> for our tutorial on <a href=\"https:\/\/qodeinteractive.com\/magazine\/create-shortcode-in-wordpress\/\">custom shortcodes<\/a> as examples. The first is the current date shortcode, which shows the current date in dd \u2013 mm \u2013 yyyy format. The second is the colored text shortcode, which displays text in your chosen color. We advise reading the custom shortcode tutorial we linked to above first, as it ties into this article. The tutorial will also provide a lot <strong>more information about the two custom shortcodes<\/strong> that we\u2019ll be using, as well as show you how to insert a shortcode call in general.[\/vc_column_text][vc_empty_space height=&#8221;28px&#8221;][vc_column_text]Even though these two shortcodes are very simple, they are useful for demonstrating adding a shortcode to an appropriate sidebar widget.<br \/>\n[\/vc_column_text][vc_empty_space height=&#8221;28px&#8221;][vc_column_text]Finally, after the WordPress 5.8 update it is possible to add blocks to widget areas and edit the <strong>Widget<\/strong> screen using the Gutenberg editor entirely, two types of WordPress users have emerged. Some still rely on the Classic Widgets screen, while others have fully embraced the Gutenberg editor and use it to edit widgets as well. For this reason, we have purposefully divided the main part of the article into two sections, catering to Classic widgets and block-based widget editor users, respectively. That said, let us proceed to the how-tos of this article.[\/vc_column_text][vc_empty_space height=&#8221;80px&#8221;][vc_widget_sidebar sidebar_id=&#8221;new-top-picks-banner&#8221;][vc_empty_space height=&#8221;80px&#8221;][\/vc_column][\/vc_row][vc_row][vc_column][vc_column_text]<\/p>\n<h2 class=\"qodef-h4\">How to Add Shortcodes to WordPress Sidebars Using the Block-based Widgets Editor<\/h2>\n<p>[\/vc_column_text][vc_column_text]Since the WordPress 5.0 update, <a href=\"https:\/\/qodeinteractive.com\/magazine\/introduction-to-wordpress-gutenberg-block-editor\/\">the Gutenberg editor<\/a> has replaced TinyMCE as the default WordPress editor. But, as of recently, the classic Widgets screen has also gone through the same change and has been replaced with a block-based Widgets editor. The block-based editor offers two ways of adding shortcodes \u2013 using the Paragraph and Shortcode block, which we will cover below.[\/vc_column_text][vc_empty_space height=&#8221;22px&#8221;]<ul class=\"qodef-unordered-list-item qodef-toc\">\n    <li>\n\t        <div class=\"qodef-ul-title-holder\">\n            <span class=\"qodef-ul-title-content\"><strong>Using the Paragraph Block<\/strong><\/span>        <\/div>\n            <\/li>\n<\/ul>[vc_empty_space height=&#8221;28px&#8221;][vc_column_text]The Paragraph block is the default block type for any text that you add to the Gutenberg editor. The text added to the Paragraph block can have some properties like being italic or aligned left, or it can be transformed into a quote or list using the Transformer button. However, what is less known is that it can also serve to add shortcodes to WordPress sidebars using the Gutenberg editor. The reason for it is that the Paragraph block will recognize shortcode calls in regular text and render them accordingly. Let us explain this.[\/vc_column_text][vc_empty_space height=&#8221;28px&#8221;][vc_column_text]First, <strong>navigate to the Appearance &gt; Widgets<\/strong> section and <strong>open the widget area<\/strong> in which you wish to add a shortcode. Then, to add a new block to the selected widget area, you can either <strong>click the \u201c+\u201d button next to the Widgets label in the top-right corner of the screen<\/strong> or the equivalent \u201c+\u201d sign at the bottom of a widget area. Using either option will add the widget at the bottom of the selected widget area, from where you can drag and drop it in the desired location later.[\/vc_column_text][vc_empty_space height=&#8221;28px&#8221;][vc_column_text]To add a Paragraph block, you only need to <strong>locate it<\/strong> within the list of available blocks and <strong>click on it.<\/strong> Luckily, the Paragraph block can be found quite easily, but you can also use the search feature if you are unable to locate it.[\/vc_column_text][vc_empty_space height=&#8221;50px&#8221;]<div class=\"qodef-single-image-holder   qodef-has-border \">\n    <div class=\"qodef-si-inner\" >\n                                    <img loading=\"lazy\" decoding=\"async\" width=\"969\" height=\"518\" src=\"https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2021\/12\/Paragraph-Widget.jpg\" class=\"attachment-full size-full\" alt=\"Paragraph Widget\" srcset=\"https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2021\/12\/Paragraph-Widget.jpg 969w, https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2021\/12\/Paragraph-Widget-300x160.jpg 300w, https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2021\/12\/Paragraph-Widget-768x411.jpg 768w, https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2021\/12\/Paragraph-Widget-620x331.jpg 620w\" sizes=\"auto, (max-width: 969px) 100vw, 969px\" \/>                        <\/div>\n<\/div>[vc_empty_space height=&#8221;38px&#8221;][vc_column_text]Then, you only need to<strong> insert the shortcode call into it<\/strong> and <strong>click the \u201cUpdate\u201d button<\/strong> in the top-right corner.[\/vc_column_text][vc_empty_space height=&#8221;50px&#8221;]<div class=\"qodef-single-image-holder   qodef-has-border \">\n    <div class=\"qodef-si-inner\" >\n                                    <img loading=\"lazy\" decoding=\"async\" width=\"969\" height=\"504\" src=\"https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2022\/12\/Insert-Shortcode.jpg\" class=\"attachment-full size-full\" alt=\"Insert Shortcode\" srcset=\"https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2022\/12\/Insert-Shortcode.jpg 969w, https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2022\/12\/Insert-Shortcode-300x156.jpg 300w, https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2022\/12\/Insert-Shortcode-768x399.jpg 768w, https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2022\/12\/Insert-Shortcode-620x322.jpg 620w\" sizes=\"auto, (max-width: 969px) 100vw, 969px\" \/>                        <\/div>\n<\/div>[vc_empty_space height=&#8221;38px&#8221;][vc_column_text]Generally speaking, a shortcode call represents a text similar to [shortcode_name], with the shortcode_name placeholder properly replaced. In some cases, the shortcode can also accept parameters, in which case you would need to insert a text similar to [shortcode_name parameter_1=&#8217;value_1&#8242; parameter_2=&#8217;value_2&#8242; parameter_3=&#8217;value_3&#8242; &#8230;], with up to as many parameter-value pairs as the shortcode accepts. As this might sound very confusing to some, it is best explained using examples.[\/vc_column_text][vc_empty_space height=&#8221;28px&#8221;][vc_column_text]For this article, we have decided to use the two shortcodes we have created for our article on custom shortcodes \u2013 the <strong>current_date<\/strong> shortcode and the <strong>colored_text<\/strong> shortcode. As for the former, since it doesn\u2019t accept any parameters, the correct call for this shortcode only involves its name, i.e. it\u2019s the [current_date] label. As for the latter, it accepts two parameters \u2013 the title and the color of the title. For this reason, the correct call for this shortcode is the following:[\/vc_column_text][vc_empty_space height=&#8221;28px&#8221;][vc_column_text]<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">[colored_text title='insert-your-title-here' title_color='insert-your-color-here']<\/pre>\n<p>[\/vc_column_text][vc_empty_space height=&#8221;28px&#8221;][vc_column_text]where both the title and color placeholders should be correctly replaced.<br \/>\n[\/vc_column_text][vc_empty_space height=&#8221;28px&#8221;][vc_column_text]Having said that, for this article, using either of the suggested shortcode calls would be sufficient, as it would showcase adding a shortcode to a sidebar widget in a very basic manner. However, for this article, we thought it would be best to go past the basics and include some <a href=\"https:\/\/qodeinteractive.com\/magazine\/tips-for-mastering-wordpress-block-editor\/\">Gutenberg editing tips<\/a>.[\/vc_column_text][vc_empty_space height=&#8221;28px&#8221;][vc_column_text]First of all, <strong>we have included both aforementioned shortcode calls<\/strong>. While these can also be part of a singular Paragraph block, even with some additional text in between, we thought it would be best if we placed them into separate Paragraph blocks. Furthermore, for display purposes, <strong>we have also included an additional Paragraph block with placeholder text in between and added a Heading block at the beginning.<\/strong>[\/vc_column_text][vc_empty_space height=&#8221;50px&#8221;]<div class=\"qodef-single-image-holder   qodef-has-border \">\n    <div class=\"qodef-si-inner\" >\n                                    <img loading=\"lazy\" decoding=\"async\" width=\"969\" height=\"518\" src=\"https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2022\/12\/Paragraph-Block-Widget.jpg\" class=\"attachment-full size-full\" alt=\"Paragraph Block Widget\" srcset=\"https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2022\/12\/Paragraph-Block-Widget.jpg 969w, https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2022\/12\/Paragraph-Block-Widget-300x160.jpg 300w, https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2022\/12\/Paragraph-Block-Widget-768x411.jpg 768w, https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2022\/12\/Paragraph-Block-Widget-620x331.jpg 620w\" sizes=\"auto, (max-width: 969px) 100vw, 969px\" \/>                        <\/div>\n<\/div>[vc_empty_space height=&#8221;38px&#8221;][vc_column_text]As an additional tip, we will note that <strong>a stack of four separate blocks can be made into a Group block if you choose to do so<\/strong>. The advantage of Group blocks is that they get access to additional options, are easier to manipulate, and can be added to <a href=\"https:\/\/qodeinteractive.com\/magazine\/how-to-export-and-import-gutenberg-blocks-in-wordpress\/\">Reusable blocks<\/a>, if you choose to do so.[\/vc_column_text][vc_empty_space height=&#8221;28px&#8221;][vc_column_text]When it comes to our example, to make the four blocks into a Group block, you will need to <strong>select all of them, press on the Group icon which appears above them<\/strong>, and <strong>select the \u201cGroup\u201d option from the submenu<\/strong>. Of course, make sure to <strong>click the \u201cUpdate\u201d button<\/strong> in the top-right corner of your screen to save your previous action(s).[\/vc_column_text][vc_empty_space height=&#8221;50px&#8221;]<div class=\"qodef-single-image-holder   qodef-has-border \">\n    <div class=\"qodef-si-inner\" >\n                                    <img loading=\"lazy\" decoding=\"async\" width=\"969\" height=\"518\" src=\"https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2022\/12\/Group-Block.jpg\" class=\"attachment-full size-full\" alt=\"Group Block\" srcset=\"https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2022\/12\/Group-Block.jpg 969w, https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2022\/12\/Group-Block-300x160.jpg 300w, https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2022\/12\/Group-Block-768x411.jpg 768w, https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2022\/12\/Group-Block-620x331.jpg 620w\" sizes=\"auto, (max-width: 969px) 100vw, 969px\" \/>                        <\/div>\n<\/div>[vc_empty_space height=&#8221;38px&#8221;][vc_column_text]Having explained that, the only thing that remains is testing the result on the front end. Ours is shown on the screenshot below.<br \/>\n[\/vc_column_text][vc_empty_space height=&#8221;50px&#8221;]<div class=\"qodef-single-image-holder   qodef-has-border \">\n    <div class=\"qodef-si-inner\" >\n                                    <img loading=\"lazy\" decoding=\"async\" width=\"969\" height=\"553\" src=\"https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2022\/12\/Paragraph-Block-Result.jpg\" class=\"attachment-full size-full\" alt=\"Paragraph Block Result\" srcset=\"https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2022\/12\/Paragraph-Block-Result.jpg 969w, https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2022\/12\/Paragraph-Block-Result-300x171.jpg 300w, https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2022\/12\/Paragraph-Block-Result-768x438.jpg 768w, https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2022\/12\/Paragraph-Block-Result-620x354.jpg 620w\" sizes=\"auto, (max-width: 969px) 100vw, 969px\" \/>                        <\/div>\n<\/div>[vc_empty_space]<ul class=\"qodef-unordered-list-item qodef-toc\">\n    <li>\n\t        <div class=\"qodef-ul-title-holder\">\n            <span class=\"qodef-ul-title-content\"><strong>Using the Shortcode block<\/strong><\/span>        <\/div>\n            <\/li>\n<\/ul>[vc_empty_space height=&#8221;28px&#8221;][vc_column_text]Apart from using the Paragraph block, which is a multi-purpose block, you can also use the Gutenberg block made specifically for adding shortcodes, i.e. the Shortcode block.<br \/>\n[\/vc_column_text][vc_empty_space height=&#8221;28px&#8221;][vc_column_text]To do so, <strong>navigate to the Appearance &gt; Widgets section<\/strong> and select the widget area in which you wish to insert a shortcode. Then, <strong>click the \u201c+\u201d sign next to the Widgets label<\/strong> in the top-left corner of your screen.<strong> Locate<\/strong> and <strong>select the Shortcode block<\/strong> from the list of available blocks. This will add the Shortcode block at the end of the selected widget area, and you can then drag and drop the block into the desired position. Then, the only thing that remains is to <strong>insert the shortcode call<\/strong> into the Shortcode block and <strong>click the \u201cUpdate\u201d button<\/strong> in the top-right corner to save the changes that you made.[\/vc_column_text][vc_empty_space height=&#8221;50px&#8221;]<div class=\"qodef-single-image-holder   qodef-has-border \">\n    <div class=\"qodef-si-inner\" >\n                                    <img loading=\"lazy\" decoding=\"async\" width=\"969\" height=\"518\" src=\"https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2022\/12\/Shortcode-Name.jpg\" class=\"attachment-full size-full\" alt=\"Shortcode Name\" srcset=\"https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2022\/12\/Shortcode-Name.jpg 969w, https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2022\/12\/Shortcode-Name-300x160.jpg 300w, https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2022\/12\/Shortcode-Name-768x411.jpg 768w, https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2022\/12\/Shortcode-Name-620x331.jpg 620w\" sizes=\"auto, (max-width: 969px) 100vw, 969px\" \/>                        <\/div>\n<\/div>[vc_empty_space height=&#8221;38px&#8221;][vc_column_text]As mentioned previously, the shortcode call is a label similar to the [shortcode_name] that could also contain parameter-value pairs, if the given shortcode accepts parameters. For the shortcodes used in our example, that means using the [current_date] label, since the current date shortcode doesn\u2019t accept parameters, and [colored_text title=&#8217;insert-your-title-here&#8217; title_color=&#8217;insert-your-color-here&#8217;], as the colored text shortcode accepts the title and title color parameters. Needless to say, you will need to change the insert-your-title-here and insert-your-color-here placeholders accordingly.[\/vc_column_text][vc_empty_space height=&#8221;28px&#8221;][vc_column_text]As said before, showcasing any one of those two shortcodes is sufficient in showing how you can add shortcodes to WordPress sidebars while using the Gutenberg editor. However, we will demonstrate both, creating the same layout as in the previous subsection. This time it will involve <strong>a Heading block, two Shortcode blocks with separate shortcode calls, and a Paragraph<\/strong> in between. Of course, making these four blocks into a Group block is optional and can be done either by adding the Group block beforehand or by converting the four blocks into a Group block afterward, as previously demonstrated.[\/vc_column_text][vc_empty_space height=&#8221;28px&#8221;][vc_column_text]For this subsection, we have opted for the former approach by <strong>clicking the \u201c+\u201d sign<\/strong> and <strong>clicking on the Group block<\/strong>. Then, we added the Heading, two Shortcode, and a Paragraph block with corresponding values shown on the screenshots below.[\/vc_column_text][vc_empty_space height=&#8221;50px&#8221;]<div class=\"qodef-single-image-holder   qodef-has-border \">\n    <div class=\"qodef-si-inner\" >\n                                    <img loading=\"lazy\" decoding=\"async\" width=\"969\" height=\"626\" src=\"https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2022\/12\/Add-Group-Block.jpg\" class=\"attachment-full size-full\" alt=\"Add Group Block\" srcset=\"https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2022\/12\/Add-Group-Block.jpg 969w, https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2022\/12\/Add-Group-Block-300x194.jpg 300w, https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2022\/12\/Add-Group-Block-768x496.jpg 768w, https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2022\/12\/Add-Group-Block-620x401.jpg 620w\" sizes=\"auto, (max-width: 969px) 100vw, 969px\" \/>                        <\/div>\n<\/div>[vc_empty_space height=&#8221;60px&#8221;]<div class=\"qodef-single-image-holder   qodef-has-border \">\n    <div class=\"qodef-si-inner\" >\n                                    <img loading=\"lazy\" decoding=\"async\" width=\"969\" height=\"650\" src=\"https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2022\/12\/Shortcode-Block.jpg\" class=\"attachment-full size-full\" alt=\"Shortcode Block\" srcset=\"https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2022\/12\/Shortcode-Block.jpg 969w, https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2022\/12\/Shortcode-Block-300x201.jpg 300w, https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2022\/12\/Shortcode-Block-768x515.jpg 768w, https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2022\/12\/Shortcode-Block-620x416.jpg 620w\" sizes=\"auto, (max-width: 969px) 100vw, 969px\" \/>                        <\/div>\n<\/div>[vc_empty_space height=&#8221;38px&#8221;][vc_column_text]Having added all the content, we have <strong>clicked the \u201cUpdate\u201d button<\/strong> and <strong>tested the results on the front end of the website<\/strong> by examining one of the posts containing the Main Sidebar widget area. The result is shown and highlighted below.[\/vc_column_text][vc_empty_space height=&#8221;50px&#8221;]<div class=\"qodef-single-image-holder   qodef-has-border \">\n    <div class=\"qodef-si-inner\" >\n                                    <img loading=\"lazy\" decoding=\"async\" width=\"969\" height=\"556\" src=\"https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2022\/12\/Shortcode-Block-Result.jpg\" class=\"attachment-full size-full\" alt=\"Shortcode Block Result\" srcset=\"https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2022\/12\/Shortcode-Block-Result.jpg 969w, https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2022\/12\/Shortcode-Block-Result-300x172.jpg 300w, https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2022\/12\/Shortcode-Block-Result-768x441.jpg 768w, https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2022\/12\/Shortcode-Block-Result-620x356.jpg 620w\" sizes=\"auto, (max-width: 969px) 100vw, 969px\" \/>                        <\/div>\n<\/div>[vc_empty_space height=&#8221;38px&#8221;][vc_column_text]As you can see by comparing the two results, you should have the same outcome when using either the Paragraph or Shortcode block to add shortcodes to WordPress sidebars using the block-based widgets editor. Thus, the choice of which to use comes to personal preference.[\/vc_column_text][vc_empty_space height=&#8221;68px&#8221;][\/vc_column][\/vc_row][vc_row][vc_column][vc_column_text]<\/p>\n<h2 class=\"qodef-h4\">How to Add Shortcodes to WordPress Sidebars Using the Classic Widgets Screen<\/h2>\n<p>[\/vc_column_text][vc_column_text]While the Block-based Widgets screen is enabled by default on every WordPress instance since the 5.8 update, there are still ways to revert this change and use the Classic Widgets screen once more. Thus, older WordPress users that are accustomed to the Classic Widgets screen and those that don\u2019t wish to use the Gutenberg editor for managing widgets can be happy, since reverting this change is quite simple.<br \/>\n[\/vc_column_text][vc_empty_space height=&#8221;28px&#8221;][vc_column_text]You only need to <a href=\"https:\/\/qodeinteractive.com\/magazine\/how-to-install-a-wordpress-plugin\/\">install and activate a plugin<\/a> called <a href=\"https:\/\/wordpress.org\/plugins\/classic-widgets\/\" target=\"_blank\" rel=\"noopener\">Classic Widgets<\/a>. Sadly, this might only be a temporary solution, as the plugin \u201cwill be supported and maintained until at least 2022, or as long as is necessary\u201d, as noted on the plugin page. Nevertheless, we will cover the ways of how you can add shortcodes to WordPress&#8217;s classic sidebar widgets. This includes adding shortcodes, i.e. shortcode calls, to a Text widget or a Custom HTML widget, respectively. Let us explain how.[\/vc_column_text][vc_empty_space height=&#8221;22px&#8221;]<ul class=\"qodef-unordered-list-item qodef-toc\">\n    <li>\n\t        <div class=\"qodef-ul-title-holder\">\n            <span class=\"qodef-ul-title-content\"><strong>Using the Text Widget<\/strong><\/span>        <\/div>\n            <\/li>\n<\/ul>[vc_empty_space height=&#8221;28px&#8221;][vc_column_text]The Text widget is one of the most useful default WordPress widgets. It allows you to add text or HTML code inside a widget area without changing any template files. When adding content to this widget, the text should be added in the Visual tab, while the HTML code must be added in the Text tab for it to render properly.<br \/>\n[\/vc_column_text][vc_empty_space height=&#8221;50px&#8221;]<div class=\"qodef-single-image-holder   qodef-has-border \">\n    <div class=\"qodef-si-inner\" >\n                                    <img loading=\"lazy\" decoding=\"async\" width=\"969\" height=\"518\" src=\"https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2021\/02\/Text-Widget-Editing-Mode.jpg\" class=\"attachment-full size-full\" alt=\"Text Widget Editing Mode\" srcset=\"https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2021\/02\/Text-Widget-Editing-Mode.jpg 969w, https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2021\/02\/Text-Widget-Editing-Mode-300x160.jpg 300w, https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2021\/02\/Text-Widget-Editing-Mode-768x411.jpg 768w, https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2021\/02\/Text-Widget-Editing-Mode-620x331.jpg 620w\" sizes=\"auto, (max-width: 969px) 100vw, 969px\" \/>                        <\/div>\n<\/div>[vc_empty_space height=&#8221;38px&#8221;][vc_column_text]Furthermore, the WordPress Text widget accepts shortcode calls (e.g. [shortcode_name]) as a valid form of text. A shortcode call added this way is then properly rendered on the website\u2019s front end to show the output of the shortcode.[\/vc_column_text][vc_empty_space height=&#8221;28px&#8221;][vc_column_text]Therefore, if you want to add a shortcode to your WordPress sidebar, for example, you can do so using a Text widget. Start by <strong>navigating to Appearance &gt; Widgets, find the widget area<\/strong> where you want to add your shortcode, and <strong>insert a Text widget into it<\/strong>. Then, <strong>add the shortcode call<\/strong> in the Visual tab and <strong>click the Save button<\/strong> below.[\/vc_column_text][vc_empty_space height=&#8221;50px&#8221;]<div class=\"qodef-single-image-holder   qodef-has-border \">\n    <div class=\"qodef-si-inner\" >\n                                    <img loading=\"lazy\" decoding=\"async\" width=\"969\" height=\"518\" src=\"https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2021\/02\/Appearance-Widgets.jpg\" class=\"attachment-full size-full\" alt=\"Appearance Widgets\" srcset=\"https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2021\/02\/Appearance-Widgets.jpg 969w, https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2021\/02\/Appearance-Widgets-300x160.jpg 300w, https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2021\/02\/Appearance-Widgets-768x411.jpg 768w, https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2021\/02\/Appearance-Widgets-620x331.jpg 620w\" sizes=\"auto, (max-width: 969px) 100vw, 969px\" \/>                        <\/div>\n<\/div>[vc_empty_space height=&#8221;60px&#8221;]<div class=\"qodef-single-image-holder   qodef-has-border \">\n    <div class=\"qodef-si-inner\" >\n                                    <img loading=\"lazy\" decoding=\"async\" width=\"969\" height=\"518\" src=\"https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2021\/02\/Text-Widget-Content.jpg\" class=\"attachment-full size-full\" alt=\"Text Widget Content\" srcset=\"https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2021\/02\/Text-Widget-Content.jpg 969w, https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2021\/02\/Text-Widget-Content-300x160.jpg 300w, https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2021\/02\/Text-Widget-Content-768x411.jpg 768w, https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2021\/02\/Text-Widget-Content-620x331.jpg 620w\" sizes=\"auto, (max-width: 969px) 100vw, 969px\" \/>                        <\/div>\n<\/div>[vc_empty_space height=&#8221;38px&#8221;][vc_column_text]We have used both of the abovementioned custom shortcodes in this example. Let us briefly explain them.[\/vc_column_text][vc_empty_space height=&#8221;28px&#8221;][vc_column_text]Since the first shortcode doesn\u2019t accept any parameters, we simply \u201ccalled\u201d it using the shortcode name, i.e. [current_date]. And, as the second shortcode accepts two parameters \u2013 title and title color \u2013 we have supplied them in the corresponding shortcode call. Furthermore, we also added some <a href=\"https:\/\/qodeinteractive.com\/magazine\/lorem-ipsum\/\"><em>Lorem Ipsum text<\/em><\/a> to visually separate the output of those two shortcodes. After adding all three, we got the output you can see below.[\/vc_column_text][vc_empty_space height=&#8221;50px&#8221;]<div class=\"qodef-single-image-holder   qodef-has-border \">\n    <div class=\"qodef-si-inner\" >\n                                    <img loading=\"lazy\" decoding=\"async\" width=\"969\" height=\"518\" src=\"https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2021\/02\/Text-Widget-Live-Preview.jpg\" class=\"attachment-full size-full\" alt=\"Text Widget Live Preview\" srcset=\"https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2021\/02\/Text-Widget-Live-Preview.jpg 969w, https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2021\/02\/Text-Widget-Live-Preview-300x160.jpg 300w, https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2021\/02\/Text-Widget-Live-Preview-768x411.jpg 768w, https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2021\/02\/Text-Widget-Live-Preview-620x331.jpg 620w\" sizes=\"auto, (max-width: 969px) 100vw, 969px\" \/>                        <\/div>\n<\/div>[vc_empty_space]<ul class=\"qodef-unordered-list-item qodef-toc\">\n    <li>\n\t        <div class=\"qodef-ul-title-holder\">\n            <span class=\"qodef-ul-title-content\"><strong>Using the Custom HTML Widget<\/strong><\/span>        <\/div>\n            <\/li>\n<\/ul>[vc_empty_space height=&#8221;28px&#8221;][vc_column_text]The Custom HTML widget, as the name indicates, is the <strong>dedicated default WordPress widget for adding custom HTML code<\/strong> into your widget areas. The HTML code that you insert is directly added to the HTML structure of the page\u2019s frontend. It will be located in the place that corresponds to the widget area where you added the Custom HTML widget.[\/vc_column_text][vc_empty_space height=&#8221;28px&#8221;][vc_column_text]Besides HTML, this widget also accepts shortcode calls and renders their output on the website accordingly. Therefore, an additional feature of this widget is adding a shortcode to a desired WordPress widget area.[\/vc_column_text][vc_empty_space height=&#8221;28px&#8221;][vc_column_text]To add a shortcode using the Custom HTML widget,<strong> navigate to Appearance &gt; Widgets<\/strong> and<strong> find the widget area<\/strong> where you want to insert the shortcode. <strong>Add a Custom HTML widget<\/strong> inside your chosen widget area and then <strong>add the shortcode call<\/strong> to it. Finish up by <strong>clicking the <em>Save<\/em> button<\/strong> below.[\/vc_column_text][vc_empty_space height=&#8221;50px&#8221;]<div class=\"qodef-single-image-holder   qodef-has-border \">\n    <div class=\"qodef-si-inner\" >\n                                    <img loading=\"lazy\" decoding=\"async\" width=\"969\" height=\"518\" src=\"https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2021\/02\/Custom-HTML-Widget.jpg\" class=\"attachment-full size-full\" alt=\"Custom HTML Widget\" srcset=\"https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2021\/02\/Custom-HTML-Widget.jpg 969w, https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2021\/02\/Custom-HTML-Widget-300x160.jpg 300w, https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2021\/02\/Custom-HTML-Widget-768x411.jpg 768w, https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2021\/02\/Custom-HTML-Widget-620x331.jpg 620w\" sizes=\"auto, (max-width: 969px) 100vw, 969px\" \/>                        <\/div>\n<\/div>[vc_empty_space height=&#8221;38px&#8221;][vc_column_text]Since we used the same two shortcode calls in this example as well as the previous one, what we said earlier applies here as well. We added the same placeholder text to visually separate the output again. However, you may have noticed on the image above that the placeholder text is wrapped inside a <a href=\"https:\/\/www.w3schools.com\/html\/html_paragraphs.asp\" target=\"_blank\" rel=\"noopener\">paragraph<\/a> tag. This is necessary because any plain text section added into the Custom HTML widget would be added directly to the HTML structure of your webpage. However, this is not the case with the Text widget, since it places plain text sections inside a paragraph by default.[\/vc_column_text][vc_empty_space height=&#8221;28px&#8221;][vc_column_text]That said, after adding all those things to the widget, the output that we got is the same as in the previous example. Inserting the same shortcodes into a Custom HTML widget and a Text widget can produce the same output.<br \/>\n[\/vc_column_text][vc_empty_space height=&#8221;50px&#8221;]<div class=\"qodef-single-image-holder   qodef-has-border \">\n    <div class=\"qodef-si-inner\" >\n                                    <img loading=\"lazy\" decoding=\"async\" width=\"969\" height=\"518\" src=\"https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2021\/02\/HTML-Widget-Live-Preview.jpg\" class=\"attachment-full size-full\" alt=\"HTML Widget Live Preview\" srcset=\"https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2021\/02\/HTML-Widget-Live-Preview.jpg 969w, https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2021\/02\/HTML-Widget-Live-Preview-300x160.jpg 300w, https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2021\/02\/HTML-Widget-Live-Preview-768x411.jpg 768w, https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2021\/02\/HTML-Widget-Live-Preview-620x331.jpg 620w\" sizes=\"auto, (max-width: 969px) 100vw, 969px\" \/>                        <\/div>\n<\/div>[vc_empty_space height=&#8221;38px&#8221;][vc_column_text]Comparing the two outputs and how the shortcode calls were added, we can conclude that both the Text and Custom HTML widget are equivalent when it comes to adding shortcodes to sidebar widgets. So, picking which one you\u2019ll use comes down to personal preference.<br \/>\n[\/vc_column_text][vc_empty_space height=&#8221;68px&#8221;][\/vc_column][\/vc_row][vc_row][vc_column][vc_column_text]<\/p>\n<h2 class=\"qodef-h4\">Final Thoughts<\/h2>\n<p>[\/vc_column_text][vc_column_text]In this article, we have taken a look at how you can use two WordPress widgets\u2014 the Text and the Custom HTML widget\u2014to add shortcodes to any widget area on your website. This will give you the freedom to adjust parts of your website that you previously might not have been able to customize. And, as the process is quite straightforward, you can accomplish your goal or realize your design in minutes. Make sure to bookmark this article, so you don\u2019t forget this often overlooked use of two versatile WordPress widgets.<br \/>\n[\/vc_column_text][\/vc_column][\/vc_row]<\/p>\n<\/div>","protected":false},"excerpt":{"rendered":"<p>What do you do when you need a new feature on your site? Use a WordPress widget to add a shortcode, of course! Don&#8217;t worry, it&#8217;s easier than it sounds.<\/p>\n","protected":false},"author":11229,"featured_media":20517,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[7],"tags":[4,13],"class_list":["post-20506","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-tutorials","tag-tips","tag-wordpress"],"_links":{"self":[{"href":"https:\/\/qodeinteractive.com\/magazine\/wp-json\/wp\/v2\/posts\/20506","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/qodeinteractive.com\/magazine\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/qodeinteractive.com\/magazine\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/qodeinteractive.com\/magazine\/wp-json\/wp\/v2\/users\/11229"}],"replies":[{"embeddable":true,"href":"https:\/\/qodeinteractive.com\/magazine\/wp-json\/wp\/v2\/comments?post=20506"}],"version-history":[{"count":0,"href":"https:\/\/qodeinteractive.com\/magazine\/wp-json\/wp\/v2\/posts\/20506\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/qodeinteractive.com\/magazine\/wp-json\/wp\/v2\/media\/20517"}],"wp:attachment":[{"href":"https:\/\/qodeinteractive.com\/magazine\/wp-json\/wp\/v2\/media?parent=20506"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/qodeinteractive.com\/magazine\/wp-json\/wp\/v2\/categories?post=20506"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/qodeinteractive.com\/magazine\/wp-json\/wp\/v2\/tags?post=20506"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}