How to use shortcodes within a WordPress Text widget?
0 62 0
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
- To begin, log into your WordPress Dashboard.
- Next, navigate to ‘Appearance’ and then ‘Editor’.
- At the list of files on the right side of the page, click on ‘functions.php’
- At the bottom of the ‘functions.php’ file, add the following code.
add_filter( ‘widget_text’, ‘shortcode_unautop’); add_filter( ‘widget_text’, ‘do_shortcode’);
- 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.
Add a comment