Moving Categories submenu to Media, but still opens Posts menu

To add to what @brasofilo answered 3 years ago, this is what is necessary in the current menu system (WP v4.5.1).

add_action( 'admin_head-edit-tags.php', 'modify_menu_highlight_wpse_43839' );

function modify_menu_highlight_wpse_43839()
{
    if( 'post_tag' == $_GET['taxonomy'] )
    {       
        ?>
        <script type="text/javascript">
            jQuery(document).ready( function($) 
            {
                $("#menu-posts, #menu-posts a")
                    .removeClass('wp-has-current-submenu')
                    .removeClass('wp-menu-open')
                    .addClass('wp-not-current-submenu'); 
                $("#menu-media, #menu-media > a")
                    .addClass('wp-has-current-submenu');
            });     
        </script>
        <?php
    }
}

Hope this helps!

Leave a Comment