Multiple Grid Loops on home page no longer working in 1.9x

Community Forums Forums General Discussion Multiple Grid Loops on home page no longer working in 1.9x

This topic is: not resolved

This topic contains 1 reply, has 2 voices, and was last updated by  Jen Baumann 1 year, 2 months ago.

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #11993

    nkohler
    Participant
    Post count: 2

    Hello!

    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

    • This topic was modified 1 year, 3 months ago by  nkohler.
    • This topic was modified 1 year, 3 months ago by  nkohler.
    #12750

    Jen Baumann
    Keymaster
    Post count: 315

    Take a look here: http://wpsmith.net/2013/genesis/genesis-grid-loop-in-genesis-1-9/


    If you need technical support for your theme please file a ticket.

    The forums are community based. Staff only monitors the forum for issues relating to the forum itself and to redirect users to where they need to go.

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.