I'm creating a plugin with some kind of offers that users can publish. User, in his custom administration panel, can managed his own offers. Offers are free and premium. If offer is premium it take place above the free offers in whole list. User can refresh premium offers daily so offer that has been refresh is landing at the top of the list.
I figured it out like this:
custom fields "premium" and if offer is "premium" the value is "2", otherwise (free offer) the value is "1".
When user is refreshing his premium offer, it's
'post_modified' is changed.
What kind of query do I have to made to make this happen: newest (with latest modified date) premium offers (with custom meta "premium" equal "2") on top of the list and other offers below it.
My actual query looks like this:
$args = array( 'post_type' => 'mycustomposttype', 'post_status' => 'publish', 'paged' => $paged, 'meta_key' => 'premium', 'orderby' => 'modified meta_value_num', 'order' => 'ASC', 'meta_query' => array( array( 'key' => 'paid', 'value' => array('paid','free'), 'compare' => 'IN' ) ), );
but the newest offer is in the end of list. even when i changed order to 'DESC'. Any help (or new way to do this) will be much appreciate.