Created
February 9, 2012 09:01
-
-
Save GaryJones/1778608 to your computer and use it in GitHub Desktop.
Genesis Grid Loop - Part 3
This file contains hidden or 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 some extra body classes to grid posts. | |
* | |
* Change the $columns value to alter how many columns wide the grid uses. | |
* | |
* @author Gary Jones | |
* @link http://code.garyjones.co.uk/genesis-grid-loop-advanced/ | |
* | |
* @global array $_genesis_loop_args | |
* @global integer $loop_counter | |
* | |
* @param array $grid_classes | |
*/ | |
function child_grid_loop_post_class( $grid_classes ) { | |
global $_genesis_loop_args, $loop_counter; | |
// Alter this number to change the number of columns - used to add class names | |
$columns = 3; | |
// Only want extra classes on grid posts, not feature posts | |
if ( $loop_counter >= $_genesis_loop_args['features'] ) { | |
// Add genesis-grid-column-? class to know how many columns across we are | |
$grid_classes[] = sprintf( 'genesis-grid-column-%s', ( ( $loop_counter - $_genesis_loop_args['features'] ) % $columns ) + 1 ); | |
// Add size1of? class to make it correct width | |
$grid_classes[] = sprintf( 'size1of%s', $columns ); | |
} | |
return $grid_classes; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment