March 21, 2013 at 6:40 am #29914
I'm using Metro theme. I have a page that uses the Blog template that lists Posts from a particular category. This page (a listing of events) needs to be shown in descending order of the events. So that the most recent added event goes on the bottom of the list. I only want this functionality on this page (and pages like it that show dated events). I want the Blog listing page to show in correct Ascending order to show the most recent blog post on the top.
Here's the page: http://www.julieberrybooks.com/events
Is there a way to do this? I tried looking up a plugin (WP Post Sorting) but it's not recently updated or supported in the latest WP version. I know I could always change the date that a post is created, but is there a way to sort posts on a per-page basis? It seems like there should be since I am able to list only a certain category of posts on a blog page (using custom fields - query_args). There's got to be a way to do this.
I would appreciate any assistance!March 21, 2013 at 8:54 am #29952
How are you creating this page? Are you using query_args as a custom field? If you are, then you should be able to do this with the value. I've set one up with value "cat=7,8,9&orderby=title&order=ASC" for a client to pull those categories and order them by title alphabetically.
So, theoretically, you could do "cat=x&orderby=date&order=DESC" (or ASC if that makes it work correctly) in addition.
March 21, 2013 at 9:05 am #29954
You absolutely rock! I guess I was scared to try that. Thanks so much. Works like a charm!March 21, 2013 at 4:22 pm #30302
I adore query_args. Glad I could help!
June 17, 2013 at 2:49 pm #46405
Do you know if there's a way to add custom fields to the query argument. I've tried a few things and it's not working.
I thought I'd try:
But that didn't work.
What I have is a custom field with a key of "last_name" and posts have different values with respect to the last name of people (there's a collection of people in a people category, the post title is a name - First Middle Last). So the custom field with the person's last name is in there so I could list these people on a blog listing page but I want to sort them by their last name.
Or would it be better if I just created a custom Blog Listing page and created a custom loop?
Any thoughts?June 19, 2013 at 12:28 pm #46785
I have a similar situation. What I did was change the slug on each person's entry to be their last name and let the query args sort by the slug. The full query args reads:
(It's a custom post type and I wanted it to show them all on one page--that's the extra code. But the relevant part is the orderby=name.) HTH
June 19, 2013 at 12:37 pm #46787
I also started a new post with this similar subject - http://www.studiopress.com/forums/topic/using-query_args-with-custom-fields/
Hopefully this will help anyone else with this challenge.
You must be logged in to reply to this topic.