Community Forums › Forums › Archived Forums › General Discussion › Grid Loop in Genesis 1.9 not working on pages
Tagged: genesis 1.9, grid loop, pages
- This topic has 14 replies, 3 voices, and was last updated 12 years ago by varickdesign.
-
AuthorPosts
-
January 15, 2013 at 3:48 pm #12123varickdesignParticipant
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
January 16, 2013 at 9:08 am #12291David DeckerMemberAs 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/
January 16, 2013 at 9:16 am #12298varickdesignParticipantDavid,
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
January 16, 2013 at 9:25 am #12301David DeckerMemberI'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.
January 16, 2013 at 9:43 am #12308varickdesignParticipantDavid,
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.
January 16, 2013 at 9:44 am #12309billericksonMemberQuery 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)January 16, 2013 at 9:48 am #12311billericksonMember(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.January 16, 2013 at 9:49 am #12312billericksonMemberQuery 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)January 16, 2013 at 10:08 am #12317varickdesignParticipantThanks 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.
January 16, 2013 at 10:10 am #12318billericksonMemberGlad I can help!
January 16, 2013 at 10:28 am #12322varickdesignParticipant@daviddecker,
I sent in a support ticket can you cancel that?
Thanks
January 16, 2013 at 11:45 am #12341David DeckerMember@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 🙂
January 16, 2013 at 3:22 pm #12425varickdesignParticipantSorry 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
January 16, 2013 at 4:42 pm #12454billericksonMember(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/
January 17, 2013 at 10:43 am #12642varickdesignParticipantThanks 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.
-
AuthorPosts
- The topic ‘Grid Loop in Genesis 1.9 not working on pages’ is closed to new replies.