Created
July 11, 2013 21:49
-
-
Save charliecm/5979566 to your computer and use it in GitHub Desktop.
Minimal shortcode sample.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// [caption]content[/caption] | |
function caption_shortcode( $atts, $content = null ) { | |
extract( shortcode_atts( array( | |
'class' => 'caption', | |
), $atts ) ); | |
return '<span class="' . esc_attr($class) . '">' . $content . '</span>'; | |
} | |
add_shortcode( 'caption', 'caption_shortcode' ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// [bartag foo="foo-value"] | |
function bartag_func( $atts ) { | |
extract( shortcode_atts( array( | |
'foo' => 'something', | |
'bar' => 'something else', | |
), $atts ) ); | |
return "foo = {$foo}"; | |
} | |
add_shortcode( 'bartag', 'bartag_func' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment