如果我理解这个问题,那么您需要的SQL
$args = array (
\'post_type\' => \'popular_music\',
\'post_status\' => \'publish\',
\'tax_query\' => array (
array (
\'taxonomy\' => \'category\',
\'operator\' => \'NOT EXISTS\',
),
),
\'posts_per_page\' => -1,
\'orderby\' => \'ID\',
\'order\' => \'DESC\',
) ;
$query = new WP_Query ($args) ;
echo $query->request ;
如果是,则这是WP\\U查询生成的SQL
SELECT SQL_CALC_FOUND_ROWS $wpdb->posts.ID
FROM
$wpdb->posts
WHERE
1=1 AND
(
NOT EXISTS
(
SELECT 1
FROM
$wpdb->term_relationships INNER JOIN
$wpdb->term_taxonomy ON $wpdb->term_taxonomy.term_taxonomy_id = $wpdb->term_relationships.term_taxonomy_id
WHERE
$wpdb->term_taxonomy.taxonomy = \'category\' AND
$wpdb->term_relationships.object_id = $wpdb->posts.ID
)
) AND
$wpdb->posts.post_type = \'popular_music\' AND
(($wpdb->posts.post_status = \'publish\'))
GROUP BY $wpdb->posts.ID
ORDER BY $wpdb->posts.ID DESC