Use WordPress shortcodes in (sidebar) widgets

You’re probably here because you noticed that your shortcode isn’t working, instead it’s just showing as text.

No worries! This is by default. There is a quick fix for this. Imagine you want to show your related posts in the sidebar or social share icons in the navigation, or anything else that you created a shortcode for.

I assume you already know how to edit your files. If not, I recommend you to always use the child theme so that you don’t overwrite any core files from your theme. After a theme update, the files will always get overwritten. A child theme doesn’t receive an update so it’s save to add new files/code.

You can also add it via Appearance > Theme editor > Your CHILD theme > functions.php

Add the following code to your functions.php

// Enable shortcodes in navigation and (sidebar) widgets.
add_filter( 'widget_text', 'do_shortcode' );

That’s it! You can now use your shortcodes as a widget or navigation item.


Read updated post to add shortcodes to navigation menu too!

Support 🐶

If you found this article helpful, got a question or spotted an error/typo... Do well to leave your feedback in the comment section or help spread it by sharing this article. If you're feeling generous (and I hope you do) you can definitely help me by getting me a cup of coffee ☕.

You may like these too!

One Comment

  • I’ve been surfing online greater than three hours today, yet I never found any attention-grabbing article like yours. It is pretty worth enough for me. In my opinion, if all webmasters and bloggers made excellent content as you probably did, the net can be a lot more useful than ever before.


Leave a Reply

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