Add or remove WordPress background management menu separator

WordPress six seven hundred and sixteen Reading mode

I wonder if you have noticed that there is an empty separator under the WordPress background dashboard and comment menu, but not under other menus, as shown below:

 Add or delete WordPress background management menu separator - Picture 1

 Add or delete WordPress background management menu separator - Picture 2

 Add or delete WordPress background management menu separator - Picture 3

 

 

 

 

 

The separator code is located in the menu. php file in the wp admin directory.

Line 62:

 $menu[4] = array( '', 'read', 'separator1', '', 'wp-menu-separator' );

Line 184:

 $menu[59] = array( '', 'read', 'separator2', '', 'wp-menu-separator' );

Many years ago, users gave feedback to the WP official that they should delete the separator. The official said that the separator was used to distinguish different management modules and was not adopted in advance. However, the separator had no style but only a height, which really had no meaning of reservation.

Remove Separator

If you look at this abrupt spacing space as I do, it is not pleasing. Here we teach you how to delete this separator. The easiest way is to directly delete the two lines of code in the menu.php file. However, the next time you update the program, you will have to delete it again, which is more troublesome. The method is once and for all:

Add the following code to the topic function template functions.php.

 function zm_remove_menu() { global $menu; unset($menu[4]); unset($menu[59]); } add_action('admin_head', 'zm_remove_menu');

If you want to delete other menu items, you can open the menu.php file to view the location number of the corresponding menu item. For example, the media is $menu [10], and add a sentence to the above code:

 unset($menu[10]);

This kind of launch.

Default menu position number

2 Dashboard 4 Separator 5 Article 10 Media 15 Link 20 Page 25 Comment 59 Separator 60 Appearance 65 Plug in 70 User 75 Tools 80 Setting 99 Separator

Note: Some plug-ins will add their own menus to the top of the article, which will affect the number above.

Attach other methods for deleting menus

open shrink

Method 1

 function remove_menus () { global $menu; $restricted = array(__('Dashboard'), __('Posts'), __('Media'), __('Links'), __('Pages'), __('Appearance'), __('Tools'), __('Users'), __('Settings'), __('Comments'), __('Plugins')); end ($menu); while (prev($menu)){ $value = explode(' ',$menu[key($menu)][0]); if(in_array($value[0] != NULL?$value[0]:"" , $restricted)){unset($menu[key($menu)]);} } } add_action('admin_menu', 'remove_menus');

Method 2

 add_action( 'admin_menu', 'my_remove_menu_pages' ); function my_remove_menu_pages() { remove_menu_page('link-manager.php'); remove_menu_page('themes.php'); remove_submenu_page( 'themes.php', 'themes.php' ); remove_submenu_page( 'themes.php', 'theme-editor.php' ); remove_submenu_page( 'themes.php', 'themes.php?page=custom-background' ); remove_submenu_page( 'widgets.php', 'theme-editor.php' ); remove_menu_page('tools.php'); remove_menu_page('upload.php'); remove_menu_page('edit-comments.php'); remove_menu_page('plugins.php'); remove_menu_page('admin.php?page=w3tc_general'); remove_menu_page('admin.php?page=better_wp_security'); remove_menu_page('admin.php?page=wpcf7'); remove_submenu_page( 'index.php', 'update-core.php' ); remove_submenu_page( 'options-general.php', 'options-discussion.php' ); remove_submenu_page( 'options-general.php', 'options-writing.php' ); remove_submenu_page( 'options-general.php', 'options-reading.php' ); remove_submenu_page( 'options-general.php', 'options-permalink.php' ); remove_submenu_page( 'options-general.php', 'options-media.php' ); }

Add separator

As a theme designer, if you want to add a separator in the theme customization menu to remind the user that it is theme specific, for example, under the media menu numbered 10, you can write:

 add_action('admin_menu', function () { global $menu; $menu[11] = ['', 'read', '', '', 'wp-menu-separator']; });

Define Separator Style

If you want to define this separator style, you can write it as follows

 function zm_separator_style(){ echo'<style type="text/css">.separator {border-bottom: 1px solid #2271b1;}</style>'; } add_action('admin_head', 'zm_separator_style');

It is also added to the topic function template functions.php.

Move Menu Position

If you want to customize the menu location, such as moving the article menu under the media menu, you can write this:

 function zm_move_menu () { global $menu; $menu[11] = $menu[5]; //  Move the article menu numbered 5 to the media menu numbered 10 unset($menu[5]); //  Remove Original Article Menu } add_action('admin_menu', 'zm_move_menu');

Others can be deduced by analogy.

 

Most of the articles on this site are original and used for personal learning records, which may be helpful to you, for reference only!

 weinxin
My Wechat
Copyright Notice
Please indicate the source and link of the original article reprinted on this site. Thank you for your cooperation!
five hundred and ninety-eight million eight hundred and forty-five thousand and six
 
 Robin
five hundred and ninety-eight million eight hundred and forty-five thousand and six
Comments six    Visitors four    Author two
    •  maqingxi
      maqingxi five

      Designers are a bit obsessive. They want to change something that doesn't meet their aesthetic standards. :mrgreen:

        •  Robin
          Robin

          @ maqingxi To be precise, it is called keeping improving

        •  Funny or not
          Funny or not three

          Amazing. Brother Bird found out all these details.

          •  pest
            pest zero

            I don't think this is incompatible. A little good differentiation

            •  simple life
              simple life four

              My brother is more sophisticated, and the style gradually likes rounded corners :cool:

                •  Robin
                  Robin

                  @ simple life I don't like rounded corners, because I used to use the theme of large rounded corners, but users like it

               anonymous

              Comment

              Anonymous netizens
               :?:  :razz:  :sad:  :evil:  :!:  :smile:  :oops:  :grin:  :eek:  :shock:  :???:  :cool:  :lol:  :mad:  :twisted:  :roll:  :wink:  :idea:  :arrow:  :neutral:  :cry:  :mrgreen:

              Drag the slider to complete validation