始终获取父类别名称Wordpress

时间:2017-05-12 14:40:14

标签: php wordpress

我只想在WordPress中获取并显示父类(或必要时的祖父母)类别名称。

我有这个:

single_cat_title()

但它显示实际的类别名称。

我的代码在header.php

在这张图片中,绿色部分必须写成" Energies Renouvelables" enter image description here

有个主意吗?

修改

这是我的代码,没有像我说的那么特别..

<div class="fil-arianne">
    <?php echo single_cat_title(); //echo get_the_title($parentID);?>
</div>

1 个答案:

答案 0 :(得分:0)

为此,您可以使用get_category_parents()。所以你会这样称呼它:

get_category_parents( $cat, true, ' &raquo; ' );

会显示如下内容:

The Parent Category » My Category » 

有关参数的完整列表,请查看codex