Php仅插入主类别
此代码用于插入主类别和子类别Php仅插入主类别,php,wordpress,categories,Php,Wordpress,Categories,此代码用于插入主类别和子类别 <?php foreach((get_the_category()) as $category){ $cat_link = get_category_link($category->cat_ID); echo '<a href="'.$cat_link.'">'.$category->name.'</a>'; } ?> 我只需要一个主要类别名称。避免在不必要时设置
<?php
foreach((get_the_category()) as $category){
$cat_link = get_category_link($category->cat_ID);
echo '<a href="'.$cat_link.'">'.$category->name.'</a>';
}
?>
我只需要一个主要类别名称。避免在不必要时设置标题(段落文本)添加更多代码,此代码仅回显此处不插入任何内容,请阅读
获取类别($id)