2024年10月19日 建站教程
wordpress文章页如何单独获取分类/栏目名称和链接,下面web建站小编给大家介绍一下详细代码。
1、获取栏目名称
<?php
foreach((get_the_category()) as $category){
echo $category->cat_name;
}
?>
2、获取栏目链接
<?php
$category = get_the_category();
if($category[0]){
echo ''.get_category_link($category[0]->term_id ).'';
}
?>
本文链接:http://so.lmcjl.com/news/15721/