Column Classes Shortcode for Genesis Theme

Add the following codes in your functions.php file

// Replace WP autop formatting
if ( ! function_exists( 'gd_remove_wpautop' ) ) {
function gd_remove_wpautop( $content ) {
$content = do_shortcode( shortcode_unautop( $content ) );
$content = preg_replace( '#^<\/p>|^<br \/>|<p>$#', '', $content );
return $content;
} // End gd_remove_wpautop()
}

/* ============= Two Columns ============= */

function gd_shortcode_one_half($atts, $content = null) {
extract(shortcode_atts( array('first' => 'no'),$atts) );
if($first == "no"){ $class = "one-half"; } else { $class = "one-half first"; }
return '<div class="' . $class . '">' . gd_remove_wpautop($content) . '</div>';
}
add_shortcode( 'one_half', 'gd_shortcode_one_half' );

/* ============= Three Columns ============= */

function gd_shortcode_one_third($atts, $content = null) {
extract(shortcode_atts( array('first' => 'no'),$atts) );
if($first == "no"){ $class = "one-third"; } else { $class = "one-third first"; }

return '<div class="' . $class . '">' . gd_remove_wpautop($content) . '</div>';
}
add_shortcode( 'one_third', 'gd_shortcode_one_third' );

function gd_shortcode_two_thirds($atts, $content = null) {
extract(shortcode_atts( array('first' => 'no'),$atts) );
if($first == "no"){ $class = "two-thirds"; } else { $class = "two-thirds first"; }

return '<div class="' . $class . '">' . gd_remove_wpautop($content) . '</div>';
}
add_shortcode( 'two_thirds', 'gd_shortcode_two_thirds' );

/* ============= Four Columns ============= */

function gd_shortcode_one_fourth($atts, $content = null) {
extract(shortcode_atts( array('first' => 'no'),$atts) );
if($first == "no"){ $class = "one-fourth"; } else { $class = "one-fourth first"; }

return '<div class="' . $class . '">' . gd_remove_wpautop($content) . '</div>';
}
add_shortcode( 'one_fourth', 'gd_shortcode_one_fourth' );

function gd_shortcode_two_fourths($atts, $content = null) {
extract(shortcode_atts( array('first' => 'no'),$atts) );
if($first == "no"){ $class = "two-fourths"; } else { $class = "two-fourths first"; }
return '<div class="' . $class . '">' . gd_remove_wpautop($content) . '</div>';
}
add_shortcode( 'two_fourths', 'gd_shortcode_two_fourths' );

function gd_shortcode_three_fourths($atts, $content = null) {
extract(shortcode_atts( array('first' => 'no'),$atts) );
if($first == "no"){ $class = "three-fourths"; } else { $class = "three-fourths first"; }
return '<div class="' . $class . '">' . gd_remove_wpautop($content) . '</div>';
}
add_shortcode( 'three_fourths', 'gd_shortcode_three_fourths' );

How to use these Shortcodes

1. One Half
[one_half first=”yes|no”]ADD CONTENT HERE[/one_half]

2. One Third
[one_third first=”yes|no”]ADD CONTENT HERE[/one_third]

3. Two Thirds
[two_thirds first=”yes|no”]ADD CONTENT HERE[/two_thirds]

4. One Fourth
[one_fourth first=”yes|no”]ADD CONTENT HERE[/one_fourth]

5. Two Fourth
[two_fourths first=”yes|no”]ADD CONTENT HERE[/two_fourths]

6. Three Fourths
[three_fourths first=”yes|no”]ADD CONTENT HERE[/three_fourths]

This site uses cookies to offer you a better browsing experience. By browsing this website, you agree to our use of cookies.