我试图查询cpt“空缺”中的5个职位。查询非常复杂。首先,我需要属于ID为18的自定义分类法并按“post\\u modified”排序的帖子,然后-cpt“空缺”中的所有其他帖子也按“post\\u modified”排序。所有这些都限制在5个职位上。
目前我使用:
$query_hot = $wpdb->get_results("(SELECT * FROM wp_posts
WHERE post_type = \'vacancy\' AND post_status = \'publish\'
AND ID IN (SELECT object_id FROM wp_term_relationships WHERE
wp_term_relationships.term_taxonomy_id = 18)
ORDER BY post_modified DESC)
UNION
(SELECT * FROM wp_posts
WHERE post_type = \'vacancy\' AND post_status = \'publish\'
AND ID NOT IN (SELECT object_id FROM wp_term_relationships WHERE
wp_term_relationships.term_taxonomy_id = 18)
ORDER BY post_modified DESC) LIMIT 5");
它查询正确的帖子,但不按“post_modified”排序。我做错了什么?