Skip to content

Instantly share code, notes, and snippets.

@bmodena
Created June 21, 2016 15:12
Show Gist options
  • Save bmodena/375b9dd319c8a0b79ada6bbd861c648b to your computer and use it in GitHub Desktop.
Save bmodena/375b9dd319c8a0b79ada6bbd861c648b to your computer and use it in GitHub Desktop.
Boostrap Grid / Cols Short Codes
/*
* BOOSTRAP GRID SHORT CODES
* Req : Bootstrap - http://getbootstrap.com/
* add this code to functions.php or a shortcodes.php include
* Use in WISIWIG
---------------------------------------------
[one_third] Content third [/one_third]
[one_third] Content third [/one_third]
[one_third] Content thrid [/one_third]
[one_half] Content half [/one_half]
[one_half] Content half [/one_half]
[one_quarter] Content one quarter [/one_quarter]
[three_quarter] Content three quarters [/three_quarter]
[one_third] Content one third [/one_third]
[two_third] Content two thirds [/two_third]
*/
/// 1/2 COLUMN
function one_half($atts, $content = null) {
return '<div class="col-md-6">'.do_shortcode($content).'</div>';
}
add_shortcode ("one_half", "one_half");
/// 1/3 COLUMN
function one_third($atts, $content = null) {
return '<div class="col-sm-6 col-md-4">'.do_shortcode($content).'</div>';
}
add_shortcode ("one_third", "one_third");
/// 2/3 COLUMN
function two_third($atts, $content = null) {
return '<div class="col-sm-6 col-md-8">'.do_shortcode($content).'</div>';
}
add_shortcode ("two_third", "two_third");
/// 1/4 COLUMN
function one_quarter($atts, $content = null) {
return '<div class="col-sm-6 col-md-3">'.do_shortcode($content).'</div>';
}
add_shortcode ("one_quarter", "one_quarter");
/// 3/4 COLUMN
function three_quarter($atts, $content = null) {
return '<div class="col-sm-6 col-md-9">'.do_shortcode($content).'</div>';
}
add_shortcode ("three_quarter", "three_quarter");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment