好的,我就是这样解决的:
//1. Get all events with meta field
$args = [
\'post_type\' => "events",
\'posts_per_page\' => -1,
\'meta_query\' => [
[
\'key\' => \'event_archive\',
\'value\' => "true",
\'compare\' => \'!=\'
]
],
\'fields\' => \'ids\',
];
$myEvents = new WP_Query( $args );
//2. Get all terms including only posts from first query
$args = [
\'taxonomy\' => \'kategorien\',
\'hide_empty\' => true,
\'orderby\' => \'slug\',
\'object_ids\' => $myEvents->posts,
];
$myTerms = get_terms( $args);