To achieve this we need to use get_the_category
here.
I am going to use this code in several places, so it is more efficient to create a function
function exclude_cats($excludedcats = array()){ $categories = get_the_category(); $separator=", "; $output=""; foreach($categories as $category) { if ( !in_array($category->cat_ID, $excludedcats) ) { $output .= 'term_id ).'" title="' . esc_attr( sprintf( __( "View all posts in %s" ), $category->name ) ) . '">'.$category->cat_name.''.$separator; } } echo trim($output, $separator); }
All that I’ve done inside the function was to call get_the_category
function, But I’ve excluded the categories I don’t want to show their names to not show.
inside the index I’ve called the function like so exclude_cats(array(11, 40, 53));