我想只显示当前帖子页面的类别名称和链接。 例如,我有一个帖子可以说" test123"我已将帖子与2个类别联系起来" ab"," bc"。但是我有5个不同的类别。所以我想只显示两个类别" ab"," bc"当用户进入" test123"页。
请参阅下面的代码,它显示了所有类别,但我只想显示与当前帖子页面链接的类别。
wp_list_categories( 'number=5' ); ?>
答案 0 :(得分:0)
<?php the_category(); ?>
或者,如果您想要更多选项:
<?php the_category( $separator, $parents, $post_id ); ?>
这样就可以了。它也可以像这样使用:
<?php $catArr = get_the_category( $id ); ?>
参考:
http://codex.wordpress.org/Template_Tags/the_category http://codex.wordpress.org/Function_Reference/get_the_category