在我的主题文章页面(single.php)中,我有以下代码过滤div,使其仅显示在特定类别上:
<?php $categoria_post = the_category_id($categoria_post);
if ($categoria_post == 760) : ?>
<div>
...
</div>
<?php endif; ?>
现在,我需要过滤其他div,只考虑分类法slug(series\\u speciais),忽略id:<?php $especiais = the_terms(\'slug\',\'taxonomy-name\');
if ($especiais == \'series_especiais\') : ?>
但上面的代码不起作用。EDIT:
此分类法的创建方式:add_action( \'init\', \'create_post_tax\' );
function create_post_tax() {
register_taxonomy(
\'series_especiais\',
\'post\',
array(
\'label\' => __( \'Séries Especiais\' ),
\'rewrite\' => array( \'slug\' => \'series_especiais\',\'with_front\' => true ),
\'hierarchical\' => true,
)
);
}