OK, first let me say “WOW”. Trying to find this information literally took me over an hour but I finally pieced it all together. You would think that the solution would be so easy to find. I just wanted to reverse the order output.
I found a ton of different ways to do it, the only problem was, NONE OF THEM WORKED!!!
But I figured it out finally… so here’s the code =)
add_action('genesis_before_loop', 'child_before_loop');
function child_before_loop () {
global $query_string;
query_posts($query_string . "&order=ASC");
}
You can actually edit any part of this code once you know the variable to put in.
For example if you wanted it in ascending order based on the title, you would do something like this:
add_action('genesis_before_loop', 'child_before_loop');
function child_before_loop () {
global $query_string;
query_posts($query_string . "&order=ASC&orderby=title");
}
So in conclusion you can pretty much edit the entire query string based on this code. Thank GOD!!
Oh yeah… and the best part is:
THIS WILL WORK ON ANY CHILD THEME!!!!!
Enjoy!

I design and develop websites with wordpress, I like anime, I play video games, and my mind is always thinking of new ideas. 








This doesn’t seem to work for me. It runs the query in ASC by title and the page runs the loop a second time as well. Something is amiss.
It definitely shouldn’t be sorting by title unless there’s something else in the query. Also, if it’s a new loop, make sure to remove the old one first. If you want, paste your code and I’ll take a look at it.
Thank you! Was pointed here via Studiopress. Exactly what I needed.
Laeh recently posted..Best Pillows for Side Sleepers
this is working global. What would I write if I only wanted this to be true for one of my categories?
you would just have to add “cat=45′, 45 being the id of the category you would want to include, in your query string. So query_posts($query_string . “&order=ASC&orderby=title&cat=45″);
This worked great, only thing is that it replaced my static home page with the news page that I had used it for. Any idea why or how I can get my static home page back to normal, but still have this work on my posts page?
http://www.carylodge198.org
Thanks!!!
it definitely shouldn’t have replace anything… If you want to use it on a specific category then you should use the “cat=45″ argument. take a look @kim comment below and see if that will work for you.
What if you simply wanted it to display pages first and post last, regardless of chronological order?
I guess I would have to see an example. Posts and Pages are different, not sure what situation would warrant you to display both… I’d love to help if you can elaborate.
We would like to have people use the search box to find product pages based on their query rather than post. Currently both posts and pages are displayed but the pages are at the end… Is there a way to write the code to simply display site pages as search results?
Hi Mark, I think the solution to this is a little more in depth then just adding a little piece to the query. I’m sure you can add arguments to the query and use post_type pages, but your solution seems to be more in the search functionality. I would try to find an advanced search plugin or something similar. I think views would work great for that. Here’s a link: http://surefirewebservices.com/go/wp-views
This works for me for title and for date either ascending or descending. Is it possible to get a random order display? I have one client who wants equitable display order and I can’t figure that out.
I think this works but not sure. Do you know or do you know how I could verify?
function child_before_loop () {
global $query_string;
query_posts($query_string . "&order=ASC&orderby=rand");
}
that looks exactly right. I would just put it in your functions file along with the rest of the code. If it doesn’t work, remove it, but it should be a quick check. Also, don’t think you need “order=ASC” if your using ‘rand’
Dear Sir,
> How do i sort older posts header A to Z ?
> Forexample;
> i have 300 more posts from ” A” category.
> İ want to make a landing page to show vizitors , category “A ” index page and
> sort posts header A to Z.
> Thank you.
Hi, take a look at the wordpress codex for different ways to sort your query. http://codex.wordpress.org/Class_Reference/WP_Query
Thank you for sharing this Great Post… I was really having trouble with sorting posts in genesis themes and tried many times but failed.. How do you this in category pages only?
You can get the category ID and use a wordpress conditional tag to target that specific category. http://codex.wordpress.org/Conditional_Tags
Worked for me, thanks for sharing!
Your very welcome!
I also encountered the issue where the home page resorted to a news page. Fixed by adding a if ( !is_page() ) wrap around it. Now works like a charm.
Thanks for the solution Lexy!
That did the trick. Thanks for posting!
Great writing. My thanks for posting this. I’ll come here to find out more and tell my coworkers about this site.
How do you sort posts by comment count?
on orderby use the statement “comment_count” without the quotes. orderby=comment_count