SFD
9th February 2010, 13:18
I have a line of code which displays which categories a post belongs to
<h3 class=cat_title><?php the_category(', '); ?> »</h3>this brings up a line at the top of each post, example:
headline, featured, mens, £100+
I am trying to alter the code so it does not display 'headline' and 'featured'
I know in wordpress there is exclude=3 + include=3 etc but they don't seem to apply to this function.
I have done lots of searching and the best I have come up with is
<?php foreach((get_the_category()) as $cat) { if (!($cat->cat_ID=='52')) echo '<a href="' . get_bloginfo('url') . '/category/' . $cat->category_nicename . '/">'. $cat->cat_name . '</a>' . ', '; } ?>Where I replace 52 with the category number. The problem with this code though is I can only exclude 1 category.
Does anyone know what code I am after, I have searched and searched but can't find a simple solution to exclude more than 1 category.
Thanks
<h3 class=cat_title><?php the_category(', '); ?> »</h3>this brings up a line at the top of each post, example:
headline, featured, mens, £100+
I am trying to alter the code so it does not display 'headline' and 'featured'
I know in wordpress there is exclude=3 + include=3 etc but they don't seem to apply to this function.
I have done lots of searching and the best I have come up with is
<?php foreach((get_the_category()) as $cat) { if (!($cat->cat_ID=='52')) echo '<a href="' . get_bloginfo('url') . '/category/' . $cat->category_nicename . '/">'. $cat->cat_name . '</a>' . ', '; } ?>Where I replace 52 with the category number. The problem with this code though is I can only exclude 1 category.
Does anyone know what code I am after, I have searched and searched but can't find a simple solution to exclude more than 1 category.
Thanks