Thursday 1 March 2018

How to Use Shortcodes in your WordPress Sidebar Widgets

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.

How to use shortcodes in 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.

Adding shortcode in Text 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.

Shortcode displayed in sidebar widget

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.

Adding shortcode inside Custom HTML widget in WordPress

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

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.

The post How to Use Shortcodes in your WordPress Sidebar Widgets appeared first on WPBeginner.



source http://www.wpbeginner.com/wp-tutorials/how-to-use-shortcodes-in-your-wordpress-sidebar-widgets/

1 comment:

  1. Hii
    Thanks for sharing your Blog
    I hope like for my service and drive you website and blog traffic and Grow your business For More Digital marketing Services

    Local Search Optimization Service

    Keyword Analysis Service

    digital marketing agency in USA

    Brand Management Service

    ReplyDelete