-
-
Save Shoora/978962a8746f1eb28a3d8d3b7d7aeea3 to your computer and use it in GitHub Desktop.
Wordpress Tag 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 | |
/* | |
* Tag Shortcode | |
* Usage: [tag type="span" class="myClass" id="firstSpan"]Lorem ipsum dolor sit amet[/tag] | |
*/ | |
function tag_shortcode( $atts, $content = null ) { | |
extract( shortcode_atts( array( | |
'class' => 'shortcode_class', | |
'id' => '', | |
'type' => 'div', | |
'style' => '' | |
), $atts ) ); | |
return '<' . esc_attr($type) . ' id="' . esc_attr($id) . '" class="' . esc_attr($class) . '" style="' . esc_attr($style) . '">' . do_shortcode($content) . '</' . esc_attr($type) . '>'; | |
} | |
add_shortcode( 'tag', 'tag_shortcode' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment