WordPress 101: Shortcodes in Sidebar Widgets

WordPress 101: Shortcodes in Sidebar Widgets

James Fawcett

Are you looking to add shortcodes to your WordPress sidebar widgets? This allows you to add cool extra features to your post content plus other sections of your website. For more information on how to achieve this, carry on reading!

Shortcodes: What Are They?

If you are unfamiliar with what exactly shortcodes are, it is best that we take a look at this first before delving into adding them in sidebar widgets! Shortcodes are very useful as they enable you to place extra cool features such as tables and contact forms in the WordPress content section.

The shortcodes are also handy as they can be used with widgets to place them in sidebars and other areas that can hold widgets.

Below, we are taking you through you how you can apply shortcodes to sidebar widgets in WordPress.

How to Add Shortcodes to Your WordPress Sidebar with Text Widgets

You have two options available to you when you are applying shortcodes to sidebar widgets in WordPress. The first option is to use the text widget. Drag and drop the text widget to the WordPress side bar. You can find this under Appearance and Widgets which is located in your dashboard. Once you have added this widget you can then place the shortcode in the text editing section of the widget. Then, remember to save your changes before exiting the page. Head on over to your website and take a look at the shortcode in action.

How to Add Shortcodes in WordPress with Custom HTML Widget

There may come a time when you want to place unique HTML code around the shortcode. However, this is unlikely to work properly if you are simply using the plain text widget. If this is the case, you will then need to instead add the shortcode with a Custom HTML widget. As a default, shortcodes cannot be implemented within a custom HTML widget. If you want to change this, you will be required to add the code add_filter( ‘widget_text’, ‘do_shortcode’ ); to the WordPress theme functions.php file or the specific site plugin. After this has been completed, a ‘Custom HTML’ widget can be added to the sidebar and place your shortcode in it. Hit the save button and this will store the new widget settings! Again, you can visit your website to take a look at this shortcode working.

Shortcode can be easily added to any WordPress website sidebar widgets and this article should help you carry out this process yourself with ease. Leave a comment if you have followed these steps to place sidebar widgets on your WordPress website.

James Fawcett

Author James Fawcett

James is a front and back end Wordpress developer, always interested in the latest technologies and enjoys building the diverse range of sites that Elementary designers throw his way!

More posts by James Fawcett