Shortcode API introduced in wordpress since 2.5 and it refers to a simple set of functions for creating macro codes for use in post content. Shortcode can be used to both with core code(theme) and plugins. For example, the following shortcode (in the post/page content) would add a image gallery into the page:
Sometimes shortcode have dynamic value where user have option to insert values in that particular option. Below example shows if need value how many slider image will show and what will be the slider width & height:
[image_gallery slides=”5″ width= “900px” height=”400px”]
Besides, shorcode may have opening and closing shortcode. Below example shows having the same option value if the slider image have Title in top then it needs to a closing shortcode.
[image_gallery slides=”5″ width= “900px” height=”400px”]Image Slider Top TItle [/image_gallery]
All the above examples can be used to insert their in rich area(editor) to invoke the content in post/page. But, if you like to use your shortcode in template where you have your own access to focus in fixed area, you can use the below code to print:
Moreover, if you have there is opening and closing shortcode then use the following code:
Remember, If there are no shortcode tags defined, then the content will be returned without any filtering. This might cause issues if a plugin is disabled as its shortcode will still show up in the post or content.
This post has already been read 1366 times!
TAGGED : Wordpress