WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm creating a custom post type and have added categories taxanomy. This can be done in two ways:

// In $args array
'taxonomies' => array('category'),

// or calling a function
register_taxonomy_for_object_type( 'category', 'my_custom_post_type_name' );

In both cases, an additional child-menu item appears in my custom post menu in the left admin menu.

Categories are already showing under Post menu, so I don't need it to display again. Any way of preventing this?

share|improve this question
up vote 4 down vote accepted

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)) {

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';
share|improve this answer
That worked like a charm. Thanks :-) – Steven Jul 4 '13 at 19:34

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.