Add the following codes in your functions.php file
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
// 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]
Leave a Reply