Shortcodes are great way to add beautiful effects to your posts with simple codes. Sometimes you want to use your Shortcodes with WordPress widget but WordPress text widget doesn’t recognize shortcodes. So we have to do a little tweak to get it working.
Here’s how to use Shortcodes within WordPress text widget :
- Log into your WordPress dashboard
- Go to Appearance -> Editor
- In the list of files on right, Select functions.php (Theme functions) file
- Now on functions.php, Add following lines at end of the code :
add_filter( 'widget_text', 'shortcode_unautop'); add_filter( 'widget_text', 'do_shortcode');
Click Update file and your shortcodes should work fine in WordPress Text Widget from now on.