Skip to Content

div_shortcode()

A shortcode to add a div tag to the WYSIWYG editor.

WordPress June 20, 2017

Usage

WordPress
[div class style]content[/div]

Parameters

class
(Optional) (String) Classes to add
Default: None

style
(Optional) (String) Inline styles to add
Default: None

close
(Optional) (String) Alternate method to close the div tag
Default: None

content
(Optional) (Mixed) The content to appear inside the div
Default: None

Request or provide clarification »

Examples

WordPress
[div class="special" style="background: red;"]This is the content of my div.[/div]
WordPress
[div]This is the content here.[div close]

Source File

Located in /libs/Shortcodes.php on line 163.

WordPress
        public function div_shortcode($atts, $content=''){
            extract(shortcode_atts(array("class" => '', "style" => '', "open" => '', "close" => ''), $atts));

            if ( $content ){
                $div = '<div class="nebula-div ' . esc_attr($class) . '" style="' . esc_attr($style) . '">' . do_shortcode($content) . '</div>';
            } else {
                if ( $close ){
                    $div = '</div>';
                } else {
                    $div = '<div class="nebula-div nebula-div-open' . esc_attr($class) . '" style="' . esc_attr($style) . '">';
                }
            }
            return $div;
        }

Override

To override or disable this shortcode, use add_shortcode() to declare the shortcode first.