Created
May 5, 2016 14:05
-
-
Save jbrz0/8f8cf6c083668b9757522d16ebbca821 to your computer and use it in GitHub Desktop.
Basic snippet for custom shortcodes in WP
This file contains hidden or 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
// Shortcode in functions.php | |
function caption_shortcode( $atts, $content = null ) { | |
return '<span class="caption">' . $content . '</span>'; | |
} | |
add_shortcode( 'caption', 'caption_shortcode' ); | |
// When used like this | |
[caption]My Caption[/caption] | |
// The output would be | |
<span class="caption">My Caption</span> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment