Removing product tag taxonomy in WooCommerce

The “product_tag” taxonomy is something that we rarely need to use in our WooCommerce projects. When it’s not used, we remove it to keep the admin interface clean. Clutter decreases usability and things in WP admin that actually don’t work can confuse even technical users.

The problem is that getting rid of product_tag taxonomy is not so easy.

Naive approach (don’t do this):

<?php

add_action('init', function() {
    unregister_taxonomy('product_tag');
}, 100);

If you just unregister it, WooCommerce will start throwing warnings in strange places (such as the REST API). Apparently, the existance of product_tag taxonomy is hardcoded deep in WooCommerce core.

A better approach is to just hide it.

<?php

/**
 * Overwrite product_tag taxonomy properties to effectively hide it from WP admin ..
 */
add_action('init', function() {
    register_taxonomy('product_tag', 'product', [
        'public'            => false,
        'show_ui'           => false,
        'show_admin_column' => false,
        'show_in_nav_menus' => false,
        'show_tagcloud'     => false,
    ]);
}, 100);

/**
 * .. and also remove the column from Products table - it's also hardcoded there.
 */
add_action( 'admin_init' , function() {
    add_filter('manage_product_posts_columns', function($columns) {
        unset($columns['product_tag']);
        return $columns;
    }, 100);
});

And that’s all you need to do!

Indrek Kõnnussaar

I'm a veteran Wordpress developer, context-driven tester, security enthusiast and the mastermind behind Codelight. I love building stuff that works and fixing stuff that doesn't.

Write me directly indrek@codelight.eu

3 Responses to “Removing product tag taxonomy in WooCommerce”

  1. ferry

    Hi Where do I paste the code to hide the tag?
    Thank you for your responce

    Reply
    • Indrek Kõnnussaar

      Your theme’s functions.php is one option.

      Reply
  2. Kimberly

    Thank you so much for this! One of my clients keeps adding product tags instead of categories, and this fixes the problem perfectly. Just added it as a snippet using the Code Snippets plugin, and added one to hide post tags as well. I really appreciate you taking the time to post this helpful solution.

    Reply

Leave a Reply

Your browser is out-of-date!

Update your browser to view this website correctly. Update my browser now

×