How to add WP Admin button to the main Navigation bar

Available with the following:
MainWP Core
Table of Contents

We moved the WP Admin link to the three-dot menu in the top right in order to streamline the navigation bar.

If you wish to return it to the main navigation sidebar, we prepared PHP and CSS code snippets.
The easiest way to apply them is by using our Custom Dashboard extension.

PHP code snippet

Place the following PHP code in the PHP tab in the Custom Dashboard extension and click Save:

add_filter( 'mainwp_main_menu', 'mycustom_mainwp_main_menu', 10, 1 );
function mycustom_mainwp_main_menu( $left_menu ) {
    $index = 10; // Position of the menu item being added.
    $sub_menu_after = array_splice( $left_menu['leftbar'], $index );

    $addition_item = array();

    $addition_item[] = 'WP Admin'; // This is the title of the menu item being added.
    $addition_item[] = ''; // Parent key.
    $addition_item[] = 'index.php'; // This is the URL of the menu item being added.
    $addition_item[] = 'custom-wp-admin-item'; // The ID attribute.
    $addition_item[] = '<i class="wordpress icon"></i>'; // This is the icon of the menu item being added. You can find all available icons here: https://fomantic-ui.com/elements/icon.html.
         
    $left_menu['leftbar'][] = $addition_item; // Add the additional item to the leftbar array.

    $left_menu['leftbar'] = array_merge( $left_menu['leftbar'], $sub_menu_after ); // Merge leftbar and $sub_menu_after arrays.

    return $left_menu; // Returns updated $left_menu array.
}

Custom Dashboard - PHP Code Snippet

CSS code snippet

Place the following CSS code in the CSS tab in the Custom Dashboard extension and click Save:

#custom-wp-admin-item {
    padding-left: 10px;
    padding-right: 10px;
    position: absolute;
    bottom: 0;
}

Custom Dashboard - CSS snippet

Still Have Questions?
Search for additional solutions in the MainWP Community or start your own discussion
MainWP Community

Table of Contents

Search MainWP.com

[searchwp_form id="1"]