How can I remove categories in menu in custom post type?

This was hacked together very quickly. I don’t for sure if there will be problems with translation, but I be there would be.

function remove_menu_from_cpt() {
  global $submenu;
  $post_type="book";
  $tax_slug = 'post_tag';
  if (isset($submenu['edit.php?post_type=".$post_type])) {
    foreach ($submenu["edit.php?post_type=".$post_type] as $k => $sub) {
      if (false !== strpos($sub[2],$tax_slug)) {
        unset($submenu["edit.php?post_type=".$post_type][$k]);
      }
    }
  }
}
add_action("admin_menu','remove_menu_from_cpt');

It used the ‘book’ post type and post tags, because that was convenient for me to test, but it pretty obvious what needs to change to make this work for your case– I believe you need:

$post_type="my_custom_post_type_name";
$tax_slug = 'category';

Leave a Comment