Community Forums › Forums › Archived Forums › General Discussion › Multiple Grid Loops on home page no longer working in 1.9x
- This topic has 1 reply, 2 voices, and was last updated 12 years, 3 months ago by
Jen Baumann.
-
AuthorPosts
-
January 14, 2013 at 9:44 pm #11993
nkohler
MemberHello!
Previously in Genesis 1.8x I was using multiple custom grid loops to display recent posts on the home page, broken out in sections, each containing recent posts from a different category.
To accomplish this I did the following:
function child_maybe_do_grid_loop() {// Amend this conditional to pick where this grid looping occurs
if ( ! is_single() && ! is_page() && ! is_archive() && ! is_search() ) {// Remove the standard loop
remove_action( 'genesis_loop', 'genesis_do_loop' );
// Add another prepared grid loop
add_action( 'genesis_loop', 'child_do_grid_loop_cat1' );
// Add another prepared grid loop
add_action( 'genesis_loop', 'child_do_grid_loop_cat2' );
// Add another prepared grid loop
add_action( 'genesis_loop', 'child_do_grid_loop_cat3' );
// Add another prepared grid loop
add_action( 'genesis_loop', 'child_do_grid_loop_cat4' );
// Use the prepared grid loop
add_action( 'genesis_loop', 'child_do_grid_loop' );// Add some extra post classes to the grid loop so we can style the columns
add_filter( 'genesis_grid_loop_post_class', 'child_grid_loop_post_class' );
}
}
In each loop I would have custom arguments for each section like this:
function child_do_grid_loop_cat1() {global $query_string, $paged;
// Ensure the arguments for the normal query for the page are carried forwards
// If you're using a Page to query the posts (e.g. with the Blog template), comment out the next line.
wp_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
// Cupcakes Category
$grid_args = array(
'features' => 0,
'feature_image_size' => 'grid-featured',
'feature_image_class' => 'alignleft post-image',
'feature_content_limit' => 250,
'grid_image_size' => 'grid-thumbnail',
'grid_image_class' => 'alignleft post-image',
'grid_content_limit' => 150,
'more' => __( 'Continue reading →', 'genesis' ),
'cat' => '5',
'posts_per_page' => 3,
);// 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( (array) $query_args, $grid_args ) );}
Now I have been reading that this method has been changed or depreciated with Genesis 1.9x. I have seen the new code and understand how I could use it to display only one category on the home page in a grid, but I do not know how to manipulate the code to accomplish what I had going on before which is multiple grid loops on the home page displaying different categories.
Anyone have any ideas?
Thanks in advance!
Neil
January 17, 2013 at 5:35 pm #12750Jen Baumann
ParticipantTake a look here: http://wpsmith.net/2013/genesis/genesis-grid-loop-in-genesis-1-9/
-
AuthorPosts
- The forum ‘General Discussion’ is closed to new topics and replies.