How To Use Shortcodes in your WordPress Theme

As a WordPress developer, I’ve had people ask me how to get shortcodes to work in a WordPress site. Shortcode is a special tag that you can enter into a text area that gets replaced with different content when actually viewing the post on the website.

If you have ever tried using gallery, map, review plugins you’ll notice unless your theme is set up for it already the actual content does not show but only the shortcode. To get the shortcode to work properly in your widgets just add the following to your functions.php file.

Now you will see the actual content and not the shortcode text appear in your widgets.

If you want to use shortcodes in your theme files we can do that as well. Perhaps you want to show a list of related posts at the end of your blog posts. Bring up the correct file and use this code:

Now you can use shortcodes anywhere you want. Simple, right?