How would I go about showing the categories a post belongs to while excluding certain categories from the list? Is there a different template tag that would work better than the_category?
Thanks in advance!
How would I go about showing the categories a post belongs to while excluding certain categories from the list? Is there a different template tag that would work better than the_category?
Thanks in advance!
Did you find the solution for this issue? Im finding the solution too. Thanks!
Exclude ONE category by ID (use the_category):
(Eg: Exclude the Category ID=10)
<?php foreach((get_the_category()) as $cat) { if (!($cat->cat_ID==10)) echo '<a href="' . get_bloginfo('url') . '/category/' . $cat->category_nicename . '/">'. ' - ' . $cat->cat_name . '</a>';} ?>
Exclude MULTI categories by ID (use the_category):
(Eg: Exclude 3 Categories ID=10,20,30)
<?php foreach((get_the_category()) as $cat) { if (!($cat->cat_ID=='10' || $cat->cat_ID=='20' || $cat->cat_ID=='30')) echo '<a href="' . get_bloginfo('url') . '/category/' . $cat->category_nicename . '/">'. ' - ' . $cat->cat_name . '</a>';} ?>
It will work for you!
EXACTLY what i needed.
Thanks a mil.
This topic has been closed to new replies.