Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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();?

share|improve this question
    
Please post an example of the code you're employing so that we can get a better idea as to what you're trying to accomplish/where you may be going awry. –  ZaMoose Mar 12 '11 at 18:33
add comment

1 Answer

<?php
foreach((get_the_category()) as $category) {
    if ($category->category_parent  == '7') {
        echo '<a href="' . get_category_link( $category->term_id ) . '" title="' . sprintf(__( "View all posts in %s" ), $category->name ) . '" ' . '>' . $category->name.'</a> ';
    }
}
?>  

All you need to do is replace 7 with whatever category you want to include

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.