Use Shortcodes in your wordpress

Shortcodes are written by providing a handler function. Shortcode handlers are broadly similar to WordPress filters: they accept parameters (attributes) and return a result (the shortcode output).

The add_shortcode() function is used to register a shortcode handler. It takes two parameters: the shortcode name (the string used in a post body), and the handler function name.

A shortcode handler function should accept one to three arguments:

  • $atts, an associative array of attributes
  • $content, the enclosed content (if the shortcode is used in its enclosing form)
  • $code, the shortcode name (only when it matches the callback name; see discussion of attributes below)
function TestShortCode_funcion( $atts ) {
	extract( shortcode_atts( array(
		'one' => 'something',
		'two' => 'something else',
	), $atts ) );

	return "one= {$one}";
add_shortcode( 'TestShortCode', 'TestShortCode_funcion' );

This creates a "[TestShortCode]" shortcode that supports two attributes: ["one" and "two"]. Both attributes are optional and will take on default options [one="something" two="something else"] if they are not provided. 

For Full reference : Go to