Reputation: 121
I'm trying to order my WordPress posts by 3 different columns in 2 different tables.
The first is post_date, it's located in wpdb->posts table.
The second is the post's meta key and meta value, located in wpdb->postmeta.
meta_key = et_payment_package
meta_value = 1 or 0
The two columns are in different tables. How do I go about ordering them? I would like to display posts with et_payment_package=1 by their original post dates as the first few posts, followed by every other post with et_payment_package=0.
Upvotes: 0
Views: 2713
Reputation: 2011
In 4.0, you can now pass an array to WP_Query as the value for orderby.
$query=new WP_Query(array(
'meta_key'=>'your_meta_key',
'orderby'=>'date your_meta_key',
'order'=>'desc'
));
Upvotes: 1