Created
July 5, 2013 19:11
-
-
Save lunaroja/5936604 to your computer and use it in GitHub Desktop.
Wordpress: DIV short code with classes and IDs
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
function div_shortcode($atts, $content = null ) { | |
extract(shortcode_atts(array('class' => '', 'id' => '' ), $atts)); | |
$return = '<div'; | |
if (!empty($class)) $return .= ' class="'.$class.'"'; | |
if (!empty($id)) $return .= ' id="'.$id.'"'; | |
$return .= '>'. do_shortcode($content) . '</div>'; | |
return $return; | |
} | |
add_shortcode('div', 'div_shortcode'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment