WordPress Shortcode API
Shortcode API
Introduced in WordPress 2.5 is the Shortcode API, a simple set of functions for creating macro codes for use in post content. For instance, the following shortcode (in the post/page content) would add a photo gallery into the page:
[ gallery ]
It enables 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.
ShortCode Variations
Take 1: Replacing Strings | my-gallery] |
Take 2: Wrapping Content | [button]Content[/button] |
Take 3: Adding Attributes | [link to=”www.net.tutsplus.com”]NetTuts+[/link |
Each shortcode implementation requires a two-step process:
1: Create the primary handler method
2: Hook up the handler to WordPress