How to make shortcode in wordpress
February 17, 2012
Shortcode is a set of function to use in your post/page content. For instance, we use contact form 7 or any gallery plugin, we use a simple code to put in our post/page content:
[contactform]
Its really easy to built. Shortcode is define in your theme file function.php. Below is a simple example to built the shortcode.
function my_short_code( $atts ){
$code = "Shortcode is really easy.";
return $code ;
}
add_shortcode( 'my_code', 'get_zipcode' );
Now we can use [my_code] as short code in our post/page content. It will generate "Shortcode is really easy" as output.