Blog

How to: Add Shortcodes into WordPress templates

Shortcode is a simple set of functions for creating macro codes for use in post content. For example, the [gallery] shortcode would add a photo gallery into the blog page or post. The shortcodes helps plugin developers to create special kinds of content (e.g. forms, content generators) that users can attach to certain pages by adding the corresponding shortcode into the page text.

If you want to add shortcodes in a template page instead of in the content of a page or post. It’s very easy. We can run any shortcodes using do_shortcode() function. Copy and paste the following script anywhere in the template/theme file, where you want display/run your shortcode content. Replace “[shortcode]“ with your shortcode.

This script was successfully tested in WordPress 3.2 Happy blogging :)