Shortcode
Register Shortcode in WordPress Theme
The shortcode is a powerful function in WordPress. The shortcode easy to use every where post, page & widget. The shortcode use by third bracket look like [shortcode]. Today I going describe on this tune “how to register shortcode in WordPress theme”.
To register shortcode need to a function in your theme functions.php file.
function shortcode_function_name( $atts ){ return "Your HTML or current here"; } add_shortcode( 'shortcode_name', '</pre> <pre>shortcode_function_name</pre> <pre>' );
This is a simple shortcode register format. On the shortcode take function & a function name which add_shortcode. On the add_shortcode have two name one is function name and another is shortcode name. When using the shortcode name by third bracket like [shortcode_name] than output show return data. Example if you save the shortcode in your theme function and use [shortcode_name] in page or post and view their show Your HTML or current here . Because we are use this on return.
Comments are closed