此代码显示帖子类别名称,但是我也需要显示页面类别名称。我需要在此代码中进行哪些更改?我正在使用“为页面创建和分配类别”插件。
<?php if ('post' == get_post_type($post->ID) && rehub_option('exclude_cat_meta') != 1) :?>
<?php $category = get_the_category($post->ID); ?>
<?php if ($category) {
if ( class_exists( 'WPSEO_Primary_Term' ) ) {
$wpseo_primary_term = new WPSEO_Primary_Term( 'category', $post->ID );
$wpseo_primary_term = $wpseo_primary_term->get_primary_term();
if (!is_numeric($wpseo_primary_term )) {
$first_cat = $category[0]->term_id;
}else{
$first_cat = $wpseo_primary_term;
}
}else{
$first_cat = $category[0]->term_id;
}
meta_small( false, $first_cat, false, false );
} endif; ?>