Skip to content

Instantly share code, notes, and snippets.

@Shoora
Forked from ChrisLTD/gist:9240291
Created June 30, 2017 23:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Shoora/978962a8746f1eb28a3d8d3b7d7aeea3 to your computer and use it in GitHub Desktop.
Save Shoora/978962a8746f1eb28a3d8d3b7d7aeea3 to your computer and use it in GitHub Desktop.
Wordpress Tag Shortcode
<?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