I have a category that is used for internal purposes. It's "Key Articles" (slug: key-articles; ID: 47).

I don't want this showing up anywhere in the site that the category taxonomy is displayed (in the post meta, in posts by category widget, etc.).

I've attempted the solution found here, using the code below, but it oddly removed the the very first category on each post, not the one I have specified. I tried using the slug, ID, and category name. Same result each time.

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

// get term to exclude by name, by id or maybe by slug
$exclude = get_term_by('slug', 'key-articles', 'category', ARRAY_A);

if (!is_admin()) {
    foreach($terms as $key => $term){
        if($term->taxonomy == "category"){
            if(in_array($key, $exclude)) unset($terms[$key]);
return $terms;

I found that solution here, where I also tried other solutions offered there, such as this one. No luck.

I am thinking newer versions of WordPress might have changed such that these methods are now useless.

What's the best way to go about it?

  • And why don’t you use custom taxonomy for that? It would be easier and you wouldn’t have to hide anything – Krzysiek Dróżdż Feb 22 at 6:49
  • @KrzysiekDróżdż It's a good point. However, it needs to fit in with functionality of a theme that makes use of Catagories taxonomy for selecting what posts display in various modules. So I am stuck with using the taxonomy the theme provides filters for. – omega33 Feb 22 at 6:54
  • i would try to change that or report it as a bug to the theme author. Using categories for such things is a really bad idea. Hiding it on the site is one thing, but then comes all the SEO stuff... Site maps, and so on... – Krzysiek Dróżdż Feb 22 at 6:56
  • Thanks @KrzysiekDróżdż - I suspect it will be much quicker and simpler to add a few lines of suitable code to a functions.php file than have Elegant Themes change the filtering options on the Blog module. :-) When it comes to SEO, I don't see how this comes into it. If the site doesn't present / output a particular Category in post metadata, etc., how does that affect SEO? If anything it improves it, because I don't want that piece of metadata to leak beyond its back-end uses on the site. – omega33 Feb 22 at 22:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.