粘贴此代码single.php
根据您的主题风格
$cats=get_the_category();
foreach($cats as $cat){
/*check for category having parent or not except category id=1 which is wordpress default category (Uncategorized)*/
if($cat->category_parent == 0 && $cat->term_id != 1){
echo \'<h2 class="link"><a href="\'.get_category_link($cat->term_id ).\'">Return</a></h2>\';
}
break;
}
输出HTML表单此代码:
<h2 class="link"><a href="(Link to first category which not have any parent category)">Return</a></h2>
Important Link:get_the_category