Created
February 9, 2012 08:54
-
-
Save GaryJones/1778584 to your computer and use it in GitHub Desktop.
Genesis Grid Loop - Part 2
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 | |
/** | |
* Prepare the grid loop. | |
* | |
* Takes care of existing query arguments for the page e.g. if it's a category | |
* archive page, then the "cat" argument is carried into the grid loop, unless | |
* it's overwritten in the $grid_args. | |
* | |
* @author Gary Jones | |
* @link http://code.garyjones.co.uk/genesis-grid-loop-advanced/ | |
* | |
* @uses genesis_grid_loop() Requires Genesis 1.5 | |
*/ | |
function child_do_grid_loop() { | |
global $query_string, $paged; | |
// Ensure the arguments for the normal query for the page are carried forwards | |
parse_str( $query_string, $query_args ); | |
// Create an array of arguments for the loop - can be grid-specific, or | |
// normal query_posts() arguments to alter the loop | |
$grid_args = array( | |
'features' => 1, | |
'feature_image_size' => 0, | |
'feature_image_class' => 'alignleft post-image', | |
'feature_content_limit' => 0, | |
'grid_image_size' => 'grid-thumbnail', | |
'grid_image_class' => 'alignleft post-image', | |
'grid_content_limit' => 0, | |
'more' => __( 'Continue reading →', 'genesis' ), | |
'posts_per_page' => 6 | |
); | |
// Make sure the first page has a balanced grid | |
if ( 0 == $paged ) | |
// If first page, add number of features to grid posts, so balance is maintained | |
$grid_args['posts_per_page'] += $grid_args['features']; | |
else | |
// Keep the offset maintained from our page 1 adjustment | |
$grid_args['offset'] = ( $paged - 1 ) * $grid_args['posts_per_page'] + $grid_args['features']; | |
// Merge the standard query for this page, and our preferred loop arguments | |
genesis_grid_loop( array_merge( $query_args, $grid_args ) ); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment