Hi,
I'm using the_category(); on my category.php template to show the category's name — the problem is that it attaches the category's parent category. Is there any way to show only child categories using the_category();?
Hi,
I'm using the_category(); on my category.php template to show the category's name — the problem is that it attaches the category's parent category. Is there any way to show only child categories using the_category();?
Did you find an answer.
It boggles my mind that there is no easy to find solution out their.
Its rather annoying as this must be very basic.
Anyone know how to do this?
Try it with this (inside the loop):
<?php
foreach((get_the_category()) as $category) {
if ($category->category_parent != 0) {
echo '<a href="' . get_category_link( $category->term_id ) . '" title="' . esc_attr(strip_tags($category->name)) . '" ' . '>' . $category->name.'</a> ';
}
}
?>This topic has been closed to new replies.