Sometimes you may want to hide specific category names from displaying in your theme, without removing the category itself or excluding the category from your home feed or archives.

But Why?

Sometimes you may use a specific category because your theme uses it to generate the content for a slider a section on the homepage. Most common would be a category called Feat, Feature, or even a category named along the lines of homepage-slider.

Yet you do not want this category to also show up as a visible name in the display of categories, whether a list of categories that post belongs to or neatly designed category labels on archive and index pages within the theme.

Pesky home-block category name display

Pesky *home-block* category name display over thumbnails.

Luckily with a little bit of code we can easily hide the category names we don’t want to be seen.

How to Hide Category Names from Showing in Your Theme

Add the following lines of code to your theme, or better even use a code snippet plugin, such as the excellent Code Snippets by Shea Bunge, and activate the snippet1.

add_filter('get_the_terms', 'hide_categories_terms', 10, 3);
function hide_categories_terms($terms, $post_id, $taxonomy){

    // define which category IDs you want to hide
    $excludeIDs = array(x);

    // get all the terms 
    $exclude = array();
    foreach ($excludeIDs as $id) {
        $exclude[] = get_term_by('id', $id, 'category');

    // filter the categories
    if (!is_admin()) {
        foreach($terms as $key => $term){
            if($term->taxonomy == "category"){
                foreach ($exclude as $exKey => $exTerm) {
                    if($term->term_id == $exTerm->term_id) unset($terms[$key]);

    return $terms;

Note: In line 05, replace x with the ID of the category you want to prevent from displaying.

One code snippet further, gone the pesky category name display is.

One code snippet further, gone the pesky category name display is.

Primary Category

If you use the YOAST SEO plugin for WordPress, you can opt to display only the primary category in your theme. Discover how to integrate the primary category in your theme in this article by Joshua Winn.

  1. This code only needs to run on the front-end, it doesn’t require to be activated everywhere if your code snippet plugin allows you to specify this.