开发者

How to remove list from <?php the_category() ?>

I am using wordpress and I am wondering how do I get just the permalink and name of the category of a post when using:

<?php t开发者_JAVA百科he_category() ?>

The above outputs a list and I just want to be able to wrap the permalink and category in my own markup


I think you want get_the_category() and get_category_link():

<?php
// everything available
foreach((get_the_category()) as $category) { 
    echo '<span><b>';
    echo $category->cat_ID . ' ';
    echo $category->cat_name . ' '; 
    echo $category->category_nicename . ' '; 
    echo $category->category_description . ' '; 
    echo $category->category_parent . ' '; 
    echo $category->category_count . ' '; 
    echo '</b></span>';
} 
?>

<?php
// heres just the name and permalink:
foreach((get_the_category()) as $category) { 
    echo $category->category_nicename . ' '; 
    echo get_category_link($category->cat_ID);;
} 
?>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜