0

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 ?

2 Answers 2

2

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 );
0

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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