Quantcast
Channel: WordPress › Support » Forum: Hacks - Recent Topics
Viewing all articles
Browse latest Browse all 8245

ferylee on "Category tags, exclude more than one category?"

$
0
0

Hi,
I have this beautiful code that prints the list of the categories which the post is assign to. I can exclude one category but now I need to exclude more than one... I try to put it in a array but somehow I don't know what I'm doing wrong.

<div class="cat_tags">
<?php
$categories = get_the_category();
$excluded_cat = '1';
$separator = ' / ';
$output = '';
if($categories){
	foreach($categories as $category) {
		if (
			$category->cat_ID != $excluded_cat
		)
			$output .= '<a href="'.get_category_link( $category->term_id ).'" title="' . esc_attr( sprintf( __( "View all posts in %s" ), $category->name ) ) . '">'.$category->cat_name.'</a>'.$separator;
	}
	echo trim($output, $separator);
}
?>
</div>

Thanks for your help,
Fery


Viewing all articles
Browse latest Browse all 8245

Trending Articles