Display the Subcategory Without the Parent Category
Many people on the Wordpress.org support forum are asking how to do this.
Here is the simple solution I came across. It will allow you to display the title of a child category without displaying the parent category.
Put this code in your template:
PHP:
-
<?php
-
$category = get_the_category();
-
?>
(Adapted from this code at Wordpress.org.)
The [1] tells it not to pull the parent category which would be [0] but instead to pull the child category which is [1]. If your hierarchy contains more layers simply change the number accordingly.



















Leave your response!