从您的问题中,我收集到您的分类术语名称与您的类别名称相匹配。如果是这种情况,并且always 如果是这样的话,为什么不直接按类别slug查询您的自定义帖子类型呢?我不知道确切的名字是什么,所以我就做了video
.
// get category slug
$cat = get_category( get_query_var( \'cat\' ) );
$cat_slug = $cat->slug;
// query your custom post type (video?), assuming
// slugs match for your category name and taxonomy term name
$my_args = array(
\'post_type\' => \'video\',
\'tax_query\' => array(
array(
\'taxonomy\' => \'your_taxonomy_name\',
\'field\' => \'slug\',
\'terms\' => $cat_slug
)
)
);
$my_query = new WP_Query($my_args);
while ($my_query->have_posts()) {
$my_query->the_post();
// do the usual thing
}