Hello, I am trying to exclude a certain category from being displayed in my sidebar; this is the code I am using today:
<h4><?php
foreach((get_the_category()) as $childcat) {
$parentcat = $childcat->category_parent;
if( $parentcat != 0 ) echo '<a href="' . get_category_link($parentcat) .'">' .get_cat_name($parentcat) .'</a>';
else echo '<a href="' . get_category_link($childcat) .'">' .$childcat->cat_name .'</a>';
}
?>
If a category is marked as both "featured" and something else, both of the categories are displayed - you can see this annoyingness in action on the sidebar of this page: [[LINK href="http://www.chitaskforce.org/criminalization/violence-criminalization/"]][[/LINK]]
I want to find out how I can exclude the "featured" category (ID 33) from the above.
Thanks for your help!
Pippin Williamson answers:
foreach((get_the_category()) as $childcat) {
$parentcat = $childcat->category_parent;
if ($childcat->cat_ID != 33)
{
if( $parentcat != 0 ) echo '<a href="' . get_category_link($parentcat) .'">' .get_cat_name($parentcat) .'</a>';
else echo '<a href="' . get_category_link($childcat) .'">' .$childcat->cat_name .'</a>';
}
}