0

As stated in the title, I try to perpetually move the "Collapse Menu" button which is normally the very last entry in the admin sidebar (backend) to the top. I googled but can't find any working solution.

I found that it is printed through wp-admin/menu-header.php. So I thought I could override this file with my child theme. But then, when a theme update changes the menu-header.php file, I would need to realize and reproduce these changes in the child theme as well. Not very practical...

Anybody got an ideas?

0

Rule of thumb is do not modify any core WordPress files. Those in the root, wp-includes, wp-admin. You could do this easily with JavaScript:

/**
 * Move the 'Collapse menu' item to the top of the admin menu
 *
 * @return void
 */
function wpse348570_move_collapse_menu() {

    ?>
        <script>
            if( jQuery( '#collapse-menu' ).length ) {
                jQuery( '#collapse-menu' ).prependTo( '#adminmenu' );
            }
        </script>
    <?php

}
add_action( 'admin_footer', 'wpse348570_move_collapse_menu' );

You can add the above as a plugin or place it into the child theme.

  • Absolutely awesome!! Works perfectly. Thanks a lot for that! – McYoda Sep 20 '19 at 8:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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