I'd like to query wp posts in custom way, I'm not sure whether or not WP_Query class can do this, but I'd like order the posts by posts that has a specific custom taxonomy and then continue with the rest of the posts.
I've tried multiple things and tried SQL custom query but I'm not SQL expert so my SQL has an error.
SELECT * FROM wp_posts AS wpost INNER JOIN wp_term_relationships ON ( wpost.ID = wp_term_relationships.object_id ) INNER JOIN wp_term_taxonomy ON ( wp_term_relationships.term_taxonomy_id = wp_term_taxonomy.term_taxonomy_id ) AND wp_term_taxonomy.taxonomy = 'location' AND wp_term_taxonomy.term_id IN ( 1191 ) INNER JOIN (SELECT * FROM wp_posts AS w2post INNER JOIN wp_term_relationships as wp2rel ON ( w2post.ID = wp2rel.object_id ) INNER JOIN wp_term_taxonomy as wp2tax ON ( wp2rel.term_taxonomy_id = wp2tax.term_taxonomy_id ) AND wp2tax.taxonomy = 'location' AND wp2tax.term_id NOT IN ( 1191 )) inn2 ORDER BY wpost.post_date DESC
Could someone help me please? Is there a better solution than this? Can WP_Query do such an order?