Last active
October 11, 2015 17:28
-
-
Save billerickson/3894060 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Add Column Classes to Display Posts Shortcodes | |
* @author Bill Erickson | |
* @link http://www.billerickson.net/code/add-column-classes-to-display-posts-shortcode | |
* | |
* Usage: [display-posts columns="2"] | |
* | |
* @param array $classes | |
* @param object $post | |
* @param object $query | |
* @return array $classes | |
*/ | |
function be_display_post_class( $classes, $post, $listing, $atts ) { | |
if( !isset( $atts['columns'] ) ) | |
return $classes; | |
$columns = array( '', '', 'one-half', 'one-third', 'one-fourth', 'one-fifth', 'one-sixth' ); | |
$classes[] = $columns[$atts['columns']]; | |
if( 0 == $listing->current_post || 0 == $listing->current_post % $atts['columns'] ) | |
$classes[] = 'first'; | |
return $classes; | |
} | |
add_filter( 'display_posts_shortcode_post_class', 'be_display_post_class', 10, 4 ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Column Classes | |
------------------------------------------------------------ */ | |
.five-sixths, | |
.four-fifths, | |
.four-sixths, | |
.one-fifth, | |
.one-fourth, | |
.one-half, | |
.one-sixth, | |
.one-third, | |
.three-fifths, | |
.three-fourths, | |
.three-sixths, | |
.two-fifths, | |
.two-fourths, | |
.two-sixths, | |
.two-thirds { | |
float: left; | |
margin: 0 0 20px; | |
padding-left: 3%; | |
} | |
.one-half, | |
.three-sixths, | |
.two-fourths { | |
width: 48%; | |
} | |
.one-third, | |
.two-sixths { | |
width: 31%; | |
} | |
.four-sixths, | |
.two-thirds { | |
width: 65%; | |
} | |
.one-fourth { | |
width: 22.5%; | |
} | |
.three-fourths { | |
width: 73.5%; | |
} | |
.one-fifth { | |
width: 17.4%; | |
} | |
.two-fifths { | |
width: 37.8%; | |
} | |
.three-fifths { | |
width: 58.2%; | |
} | |
.four-fifths { | |
width: 78.6%; | |
} | |
.one-sixth { | |
width: 14%; | |
} | |
.five-sixths { | |
width: 82%; | |
} | |
.first { | |
clear: both; | |
padding-left: 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment