经过一些研究,我得出以下结论
// Get the posts in that category with the required tag
$args = array(
\'post_type\' => [\'documents\',\'news\'],
\'fields\' => \'ids\', // Only get post IDs
\'posts_per_page\' => -1,
\'tax_query\' => array(
array(
\'taxonomy\' => \'forms\',
\'field\' => \'slug\',
\'terms\' => $symbol
)
)
);
$posts_array = get_posts( $args );
$categories = wp_get_object_terms($posts_array, [\'sources\',\'articles\'], [\'fields\' => \'id=>name\']);