实际上,我以不同的方式使用该代码来获取当前的分类名称:
<?php
$tax = $wp_query->get_queried_object();
$args = array(
\'posts_per_page\' => -1,
\'post_type\' => \'conseil\', // Custom Post Type like Movies
\'tax_query\' => array(
array(
\'taxonomy\' => \'type-conseils\', //Custom Taxonomy Name
\'field\' => \'slug\',
\'terms\' => array(
$tax->name
)
)
)
);
$new = new WP_Query($args);
if (have_posts()):
while ($new->have_posts()) : $new->the_post();
// do things
?>