Skip to content

Instantly share code, notes, and snippets.

@charliecm
Created July 11, 2013 21:49
Show Gist options
  • Save charliecm/5979566 to your computer and use it in GitHub Desktop.
Save charliecm/5979566 to your computer and use it in GitHub Desktop.
Minimal shortcode sample.
<?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' );
<?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