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

ADD CONTENT HERE

2. One Third

3. Two Thirds

ADD CONTENT HERE

4. One Fourth

ADD CONTENT HERE

5. Two Fourth

ADD CONTENT HERE

6. Three Fourths

ADD CONTENT HERE

Share This Article

Subscribe Membership Plan ($9.99/mo)

  • Get full access to all premium tutorials
  • Get Support for the posted content
  • Request for specific how-to tutorials
  • Cancel the subscription at anytime

Reader Interactions

Leave A Reply

Your email address will not be published. Required fields are marked *