正如评论中所建议的,这里最好的方法是使用tax_query
. 特别是在使用多个分类法时(在本例中),您有更大的灵活性和运行更复杂查询的能力category
和post_tag
).
你可以试试这样的
$args = [
\'tax_query\' => [
\'relation\' => \'AND\',
[
\'taxonomy\' => \'category\',
\'field\' => \'term_id\',
\'terms\' => the_field(\'troubleshooting_category\'),
\'exclude_children\' => true
],
[
\'taxonomy\' => \'post_tag\',
\'field\' => \'term_id\',
\'terms\' => 5,
],
],
];
$q = get_posts( $args );