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.
SELECT * FROM wp_posts INNER JOIN wp_postmeta ON wp_postmeta.post_id=wp_posts.ID WHERE post_type='project' AND meta_key='et_payment_package' ORDER BY et_payment_package DESC, post_date DESC;This is the resulting SQL query I've crafted, but I'm unsure how to do this with WP_query. - Procrastinatus