1

I'm adding an additional taxonomy to the Posts post-type and would like it to appear between Categories and Tags in the control panel Posts sub-menu. I know when registering custom post types you can set the control panel menu position via the menu_position argument, but I can't find anything similar for custom taxonomies - they just seem to be added to the bottom of the list.

Anyone know of a way to do this? Thanks!

1 Answer 1

2

Unluckily does not exist a clean way to do this, because register taxonomy doesn't provide a menu_order argument.

But you can act on global $submenu variable and reorder it, something like

add_action( 'admin_menu', function() {
  global $submenu;
  $found = FALSE;
  $before = $after = array();
  $tax_slug = 'my_custom_tax'; // change your taxonomy name here
  foreach ( $submenu['edit.php'] as $item ) {
    if ( ! $found || $item[2] === 'edit-tags.php?taxonomy=' . $tax_slug ) {
      $before[] = $item;
    } else {
      $after[] = $item;
    }
    if( $item[2] === 'edit-tags.php?taxonomy=category' ) $found = TRUE;
  }
  $submenu['edit.php'] = array_values( array_merge( $before, $after ) );
}, 0 );
1
  • Thanks! I ended up using a plugin but I appreciate the answer. Good to know I wasn't going crazy looking for a clean way to handle it. :)
    – Michelle
    Commented Oct 30, 2014 at 15:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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