How To Enable Shortcodes in Widgets, Comments and Excerpts

In WordPress, you can use shortcodes in the content of your pages and posts. Unfortunately, when you attempt to use shortcodes in Widgets, it won’t work properly — the WordPress default behavior is to output the text of the shortcode, instead of processing it:

[my-shortcode]

There is a way to enable shortcodes in widgets, comments, and excerpts in WordPress, by using the “do_shortcode” function. Add the following code to your functions.php file:

Now, when you go to use the shortcode, it will be processed on the page as expected.

Leave a Reply

Your email address will not be published. Required fields are marked *