我想做的是(例如):列出属于“流行”类型艺术家的所有音乐会。
您可以通过两个步骤完成:
// 1. Get all the pop artist IDs
$artist_ids = get_posts( array(
\'fields\' => \'ids\',
\'post_type\' => \'artist\',
\'genre\' => \'pop\'
) );
// 2. Get all the concerts associated to those artists
$artist_ids = implode( \',\', array_map( \'absint\', $artist_ids ) );
$concerts = $wpdb->get_results( "
SELECT * FROM $wpdb->posts
WHERE post_type = \'concert\'
AND post_status = \'publish\'
AND post_parent IN ({$artist_ids})
ORDER BY post_date DESC
" );
WP\\u查询中有一个post\\u parent参数,但它
doesn\'t accept an array, 因此直接查询。