For the plugin I'm building I have added a submenu as a child to a custom main menu item in admin. The submenu page is an edit-tags.php page. This shows up as intended under the main menu item. When clicking on this sub menu item, the user is taken to the correct page, however, the main menu item collapses back down, hiding the currently open sub menu item.

My initial feeling is that the parent slug attribute is wrong, but other submenus I have added use the same parent slug attribute and they work correctly. I'm clearly missing some option in the add_submenu_page() function, but I cannot figure out what.

Here is how I am registering the sub menu:

$this->plugin_screen_dashboard = add_submenu_page(
    $this->plugin_slug, // Parent slug
    __( 'Subscriber Lists', $this->plugin_slug ), // Page title
    __( 'Subscriber Lists', $this->plugin_slug ), // Menu title
    'manage_options', // Capability
    'edit-tags.php?taxonomy=subscriber_list&post_type=subscriber' // Menu slug


Here is how I register the main menu item:

$this->plugin_screen_hook_suffix = add_menu_page(
    __( 'My Plugin', $this->plugin_slug ), // Page title
    __( 'My Plugin', $this->plugin_slug ), // Menu title
    'manage_options', // Capability
    $this->plugin_slug, // Menu slug
    array( $this, 'display_plugin_admin_page' ), // Function
    'dashicons-plus-alt' // Icon url
  • Is your main menu item for the custom post type subscriber, or something entirely different? Jul 15, 2014 at 12:33
  • It's not actually connected to any post type - I've edited my question to show how I call the main menu item
    – tommyf
    Jul 15, 2014 at 17:38
  • Is there now (April 2023) a solution for this available?
    – JShinigami
    Apr 24, 2023 at 12:44

4 Answers 4


I had a similar issue and was able to resolve the improper menu behavior by using the parent_file filter. $parent_file is set in the /wp-admin/edit-tags.php file, but it needs to be altered based on your use case.

add_filter('parent_file', 'filter_subscriber_menu');

function filter_subscriber_menu($file) {
    $screen = get_current_screen();
    if ('edit-tags' === $screen->base && 'subscriber' === $screen->post_type) {           
    // in my case I drilled down to if($screen->id...); I used what you posted in your if clause above     
    $file = {$this->plugin_slug}; //probably need to set this as a string; for the parent slug represented by $this->plugin_slug ;  
return $file;


The problem can be solved as follows: https://developer.wordpress.org/reference/hooks/parent_file/#comment-3504

I solved it for me like this:

add_filter( 'parent_file', function( $parent_file ) {
    if ( 'edit.php?post_type=subscriber' === $parent_file ) {
        return $this->plugin_slug;

    return $parent_file;
} );

I've managed to solve this using Javascript to 'open' the menu item when on the edit tags page in the plugin.

Relevant plugin PHP file

$screen = get_current_screen();
// Check we're only on the edit-tags page in the plugin
if ('edit-tags' === $screen->base && 'subscriber' === $screen->post_type) {
    wp_enqueue_script( $this->plugin_slug . '-subscriber-edit-tags-script', plugins_url('assets/js/subscriber-edit-tags.js', __FILE__ ), array('jquery') );

subscriber-edit-tags.js (using jQuery)

(function ( $ ) {
     * File is called only when on edit tags under subscriber post type

        .addClass('wp-has-current-submenu wp-menu-open')


For anyone that's looking at this now (March 2019), unfortunately this problem still exists in 5.1...!

So the HTML elements in the WP menu have changed, so now this jQuery script works:

jQuery(document).ready( function($) {
    .addClass("wp-has-current-submenu wp-menu-open")

    $("#menu-posts-sdesk-kb a.wp-not-current-submenu")
    .addClass("wp-has-current-submenu wp-menu-open")
  • sdesk-kb = my CPT taxonomy name

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.