Add shortcode with attributes
This snippet is used to create a shortcode function for wordpress. This demonstrates the use of attributes as well.
Code Markup
function function_shortcode( $atts ) {
$atts = shortcode_atts( array(
'foo' => 'var1',
'baz' => 'var2'
), $atts, 'call_shortcode' );
return "foo = {$atts['foo']}";
}
add_shortcode( 'call_shortcode', 'function_shortcode' );