• Okay, so I am using a custom field called ‘reviews’. Posts using this field will contain a number from 1 to 5. What I’m trying to do is order posts from the highest number down to the lowest number, which I can achieve using the following code:

    query_posts('meta_key=reviews&meta_compare=<=&meta_value=5&orderby=meta_value&order=DESC');

    Now this works great, but the problem is that I also want the ordered post to be chronological too, so if I have two posts with the custom field value 5 I want the most recent post to be higher in a list than the older one.

    Is this even possible? Or is it something that can only be achieved with a plug in?

    Many thanks.

Viewing 3 replies - 1 through 3 (of 3 total)
  • Did you figure this one out? Let me know because I’ve been tearing my hair out for a couple of days on this one too.

    I don’t have such setup to test it but just wondering what will happen if you append orderby again?

    In any case I will solve this by getting the ID and publish date and inserting them to an array then sort the array by date and then publish them.

    Thread Starter codeamatuer

    (@codeamatuer)

    Thank you for your feedback nsathees. That sounds a pretty good idea. I’m a bit of a tinkerer when it comes to php – not really that competent but will attempt to try this out – arrays definitely seem the way to go.

    I’ll let you know how i get on and if this is successful as it will help others who have this problem.

    Cheers.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Can't seem to sort by custom field value AND then by date?’ is closed to new replies.