Skip to content

Instantly share code, notes, and snippets.

@lunaroja
Created July 5, 2013 19:11
Show Gist options
  • Save lunaroja/5936604 to your computer and use it in GitHub Desktop.
Save lunaroja/5936604 to your computer and use it in GitHub Desktop.
Wordpress: DIV short code with classes and IDs
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