2009-06-03 118 views

回答

26

使用get_the_category()这样的:

<?php 
foreach((get_the_category()) as $category) { 
    echo $category->cat_name . ' '; 
} 
?> 

它返回一个列表,因为一个帖子可以有多个类别。

The documentation也解释了如何从循环之外做到这一点。

20

您可以使用

<?php the_category(', '); ?> 

这将输出他们在一个逗号分隔的列表。

你也可以做标记相同的还有:

<?php the_tags('<em>:</em>', ', ', ''); ?> 
相关问题