WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am trying to find some way when using WP_Query of ordering by multiple meta_values. I know I can order by multiple values and I know how to order by meta_values but I cant seem to figure out how to do multiple meta_values. Is it possible ?

share|improve this question
up vote 2 down vote accepted

you can also store it like yyyy-mm-dd and and use

$date_array = explode( '-', $date_string );

to make it into an easy to manage array. or even better change it into a unix timestamp with

$unix_time = strtotime( $date_string );

php loves to work with unix time stamps, it's the native format.

and when you're ready to store the value again in the meta field use this to get the proper format again

$date_string = date( 'Y-m-d', $unix_time );
share|improve this answer

As far as I can tell this is currently impossible, but in my case anyway I was doing dates so I just stored the date as a string in format yyyymmdd and ordered it by that, using strlen to sort it out on the other side

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.