1. Home
  2. CMS
  3. WordPress
  4. How to use shortcodes within a WordPress Text widget?

How to use shortcodes within a WordPress Text widget?

How to use shortcodes within a WordPress Text widget?
How to use shortcodes within a WordPress Text widget?

By default, WordPress shortcodes won’t function inside of Text widgets.
However, if you require this functionality, it is simple to accomplish by following the steps below.

Using Shortcodes in a WordPress Text Widget

  1. To begin, log into your WordPress Dashboard.
  2. Next, navigate to ‘Appearance’ and then ‘Editor’.
  3. At the list of files on the right side of the page, click on ‘functions.php’
  4. At the bottom of the ‘functions.php’ file, add the following code.
add_filter( ‘widget_text’, ‘shortcode_unautop’);
 add_filter( ‘widget_text’, ‘do_shortcode’);

  1. Click ‘Update File’, your shortcodes should now work in your Text widgets.Any changes you’ve done to those files may get overwritten when a theme updates. It is recommended to always make those kinds of modifications in a child theme.
    Click ‘Update File’, your shortcodes should now work in your Text widgets.
Updated on December 23, 2018

Was this article helpful?

Related Articles

Leave a Comment

[apsl-login-lite login_text='Please login with a social account']