I want to sort my content. I’d like to sort it on two custom meta_keys (the status and the deadline).
So far I’ve got this:
$mypost = array(
'post_type' => 'customposttype',
'order' => $_GET['order'], //ASC
'orderby' => $_GET['orderby'], //meta_value
'meta_key' => $_GET['meta_key'], //status
'meta_value' => $_GET['meta_value'] //live
);
$loop = new WP_Query( $mypost );
With the following url I can achieve this query:
<a href="<?php echo add_query_arg(array ('orderby' => 'meta_value', 'meta_key' => 'status', 'meta_value' => 'live', 'order' => 'ASC'));?>">Show status=live results</a>
The bottomline is:
I also want to sort them on ‘status=live’ and ‘deadline’.
The deadline is also a ‘meta_key’. Anyone out here know what my query should be like!?
I don’t know hows you fetching the result through link, Take a look on the below code example to prepare a query args for meta key-values. I have not tested it before, Please let me know if it works for you.
take a look on the given link that might help you more WP_Query