Exclude cats from the_category()

//Exlude cats from the_category()
function incomplete_cat_list($separator) {
$first_time = 1;
foreach((get_the_category()) as $category) {
if ($category->cat_name != 'ExcludeCat1' && $category->cat_name != 'ExcludeCat2') {
if ($first_time == 1) {
echo '<a href="' . get_category_link( $category->term_id ) . '" title="' . sprintf( __( "View all posts in %s" ), $category->name ) . '" ' . '>' . $category->name.'</a>';
$first_time = 0;
} else {
echo $separator . '<a href="' . get_category_link( $category->term_id ) . '" title="' . sprintf( __( "View all posts in %s" ), $category->name ) . '" ' . '>' . $category->name.'</a>';
}
}
}
}

//Add the above code to functions.php

//Use this to call the function <?php incomplete_cat_list(', '); ?>

0 Comments

You must be logged in to post a comment.