get_category_parents

CATEGORY TAG

What It Does

Lists the current category along with all its parent categories, arranged in order by its numerical ID.

Code

<?php echo(get_category_parents(category, display link, separator, nice name)); ?>

Category

Which category to lookup and return it’s parents. By default, the current category and it’s parents will be used, but you can manually specify another category to lookup by inserting its numerical ID here.

Display Link

Setting this to FALSE will only display the name of the category. TRUE will display the name of the category and also link the name to its actual location.

Separator

What characters to use in between each category name.

Nice Name

By default, the category name is shown. You can choose to display the category “nice name” by setting this to TRUE.

Example

<?php echo(get_category_parents($cat, TRUE, ‘, ‘)); ?>

In the above example, the current category will be displayed with its parents, and each category name will link to its actual location. In between each category name, we will use the seperator of a comma.

This would return something like:

News, Technology, Mobile Phones