Grid Loop in Genesis 1.9 not working on pages

Community Forums Forums General Discussion Grid Loop in Genesis 1.9 not working on pages

This topic is: resolved

This topic contains 14 replies, has 3 voices, and was last updated by  varickdesign 1 year, 9 months ago.

Viewing 15 posts - 1 through 15 (of 15 total)
  • Author
    Posts
  • #12123

    varickdesign
    Participant
    Post count: 11

    We have a site that has a page that pulls in other pages using the old grid loop in Genesis 1.8.  This is no longer working in Genesis 1.9

    Here is the code that we are using.

    https://gist.github.com/4542358

    Looked at the different tutorials that are out there but they don’t seem to work for this circumstance.

    Can anyone help?

    Thank you

    #12291

    David Decker
    Moderator
    Post count: 95

    As of my knowledge your code will no longer work, correct.
    The use of this plugin ( http://wordpress.org/extend/plugins/genesis-grid-loop/ ) works only for pre-defined listings of posts, being that blog posts or content archives.
    However, I would still suggest to ask for support from the developer of that linked plugin.

    Genesis developer Travis Smith has also posted about this issue, maybe it could help you too: http://wpsmith.net/2013/genesis/genesis-grid-loop-in-genesis-1-9/


    #12298

    varickdesign
    Participant
    Post count: 11

    David,

    Thanks for replying.

    We are not using the plugin ( http://wordpress.org/extend/plugins/genesis-grid-loop/ )  we are just coding it and we did go over the Travis Smith http://wpsmith.net/2013/genesis/genesis-grid-loop-in-genesis-1-9/ and Bill Erickson tutorials and they are still no help because they don’t address the issue.

    What we are doing is querying for pages with a meta and then sorting and then placing after the main page content.

    Any help would be appreciated.

    Thank you

    #12301

    David Decker
    Moderator
    Post count: 95

    I’ve pinged Bill & Travis if they could have a look here.

    IMHO, your issue might be a bit more complicated and I am currently not able to do some help in resolving it.

    Due to changes in WordPress core the custom grid loops in Genesis became an issue. Plugins like that from Bill Erickson do the queries the WordPress way and displaying the output via CSS column classes – which is the future-proof way to go.

    Hope this helps for the moment.


    #12308

    varickdesign
    Participant
    Post count: 11

    David,

    Thanks for following up and pinging Bill and Travis.  We were going to do that ourselves but figured we should follow some protocol on the forums.

    Just out of curiosity.

    “Due to changes in WordPress core the custom grid loops in Genesis became an issue.”

    Was is it the core that changed or has it been that the Grid has always been inefficient or awkward that necessitated the change?

    “Plugins like that from Bill Erickson do the queries the WordPress way and displaying the output via CSS column classes – which is the future-proof way to go”.

    A plugin that has been designed like this by Bill is that a core product of Genesis or is it separate?   BTW we did try using the grid plugin but it did not address our query.

    Thanks again for following up.

    #12309

    billerickson
    Participant
    Post count: 16

    Query arguments in the grid loop are now ignored.  This is because most uses of the grid loop were for displaying the main query (ex: blog posts on your blog page, category page…), and providing query arguments like ‘posts_per_page’ lead to 404 errors. Unfortunately this also means you can’t use it for custom loops, like you were doing.

    Take a look at the staff_do_grid_loop() function here: https://gist.github.com/4548000 (I wrote it directly in the Gist so can’t guarantee it’s perfect).

    First you specify your query arguments, then create a new loop like this: $loop = new WP_Query ($args );
    Then you loop through this: if( $loop->have_posts() ): while( $loop->have_posts() ): $loop->the_post();
    Then you specify the markup for each post. I’m wrapping them in a div with either a class of “one-half first” or “one-half” depending on the post count. Inside this div, I have the title hyperlinked and the excerpt.
    Finally, once you’re done with your loop run wp_reset_postdata(); . This reverts the $post object back to the original query’s.

    For more information:

    Custom WordPress Queries (for custom queries)
    Customizing the WordPress Query (for the main page query)
    A better, easier grid loop (this is for the main query, but the example I provided in this post takes the idea and applies it to a custom query)

     

    #12311

    billerickson
    Participant
    Post count: 16

    (hopefully my long, previous reply will show up sometime. Here it is: https://gist.github.com/4548117 )

    @varickdesign, there was no change to WordPress core that made this an issue. The problem is that the grid loop was poorly constructed to begin with. When modifying the main query (which this was originally designed for), you need to separate the actual query from the formatting. Read my blog posts at the bottom of the previous post for more information.

    #12312

    billerickson
    Participant
    Post count: 16

    Query arguments in the grid loop are now ignored. This is because most uses of the grid loop were for displaying the main query (ex: blog posts on your blog page, category page…), and providing query arguments like ‘posts_per_page’ lead to 404 errors. Unfortunately this also means you can’t use it for custom loops, like you were doing.

    Take a look at the staff_do_grid_loop() function here: https://gist.github.com/4548000 (I wrote it directly in the Gist so can’t guarantee it’s perfect).

    First you specify your query arguments, then create a new loop like this: $loop = new WP_Query ($args );
    Then you loop through this: if( $loop->have_posts() ): while( $loop->have_posts() ): $loop->the_post();
    Then you specify the markup for each post. I’m wrapping them in a div with either a class of “one-half first” or “one-half” depending on the post count. Inside this div, I have the title hyperlinked and the excerpt.
    Finally, once you’re done with your loop run wp_reset_postdata(); . This reverts the $post object back to the original query’s.

    For more information:

    Custom WordPress Queries (for custom queries)
    Customizing the WordPress Query (for the main page query)
    A better, easier grid loop (this is for the main query, but the example I provided in this post takes the idea and applies it to a custom query)

    #12317

    varickdesign
    Participant
    Post count: 11

    @billerickson,

    Thanks for replying.

    So based on the coding you rewrote on gist you suggest using new WP_Query. That makes perfect sense and we are more acclimated to using this because of our development in Thesis.

    Thanks for posting up the code – we can take it from here.

    Appreciate your input. BTW – you were one of the reasons we were able to get going in Thesis and when you moved over to Genesis we followed also.

    Thanks again for your contributions.

    #12318

    billerickson
    Participant
    Post count: 16

    Glad I can help!

    #12322

    varickdesign
    Participant
    Post count: 11

    @daviddecker,

    I sent in a support ticket can you cancel that?

    Thanks

    #12341

    David Decker
    Moderator
    Post count: 95

    @varickdesign
    Sorry, no, I am just an unpaid volunteer community moderator, not StudioPress staff. here. But if you get a respond from support just point them to this thread here :)

    Thanks, Dave :)


    #12425

    varickdesign
    Participant
    Post count: 11

    @billerickson,

    Sorry one last item. Pagination.

    Reworked the code you put up but we are now having an issue with pagination.
    Here is the code we are using:

    We have added:
    ‘paged’ => get_query_var( ‘paged’ ),

    and

    genesis_posts_nav();

    But not working. Any help would be greatly appreciated.

    Thanks

    #12454

    billerickson
    Participant
    Post count: 16

    (my responses keep getting lost. I responded to this a while ago)

    The issue is that the pagination functions use the main query, not your custom one. So a hacky workaround is to overwrite the main query with your new one (assign your query to $wp_query instead of $loop).

    At the end, include wp_reset_query() which resets $wp_query and $post. wp_reset_postdata() only does the $post.

    Example: http://www.billerickson.net/code/pagination-in-a-custom-query/

     

    #12642

    varickdesign
    Participant
    Post count: 11

    @billerickson

    Thanks for following up – for some reason we did not see your reply but we were able to figure out before your reply came up.

    Here is what we did which goes with what you replied back.

    Thanks again for your generosity and knowledge.

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

The topic ‘Grid Loop in Genesis 1.9 not working on pages’ is closed to new replies.