How to Use a WordPress Shortcode Outside the Post Editor
read more
Categories

How to Use a WordPress Shortcode Outside the Post Editor


Shortcodes in WordPress are amazing. They are essentially macros that allow you to place content anywhere on your site.

For example, instead of inserting a whole bunch of images to create a gallery, you simply use the shortcode [ gallery ]. WordPress offers a few shortcodes by default and there are hundreds to choose from via available plugins.

There are a couple of places you may want to use shortcodes outside of your post content. Sidebar widgets for one, and perhaps somewhere inside your theme (in the footer, for example). In this post we’ll take a look at how you can make this happen.

Some widgets you use via plugins may support the insertion of shortcode, however the default text widget does not. To make sure shortcodes are indeed applied properly you can use a single line of code, pasted into your theme’s functions.php file.