Wordpress: Sort posts by meta value after AFTER querying from database
- by Joseph Carrington
Hello, I am pulling posts from my database by using Wordpress' WP_Query object like so:
$shows_query = new WP_Query("category_name=shows&meta_key=band&meta_value=$artist_id");
I have another meta value I would like to sort the posts by, however. The meta key is 'date'.
The WP_Query object can no work with multiple meta_keys, so this does not work:
$shows_query = new WP_Query("category_name=shows&meta_key=band&meta_value=$artist_id&meta_key=date&orderby=meta_value&order=DESC");
So now I have to figure out a way to sort the posts in $shows_query['posts'] by one of their meta_values, which are not even IN their array. Any other, more sensible approach would also be appreciated.