0

I am trying to add a menu item which is supposed to be a separator which has a height set and divides items in the menu. I haven't managed to create a menu item which isn't a link.

add_action( 'admin_menu', 'add_admin_menu_separator' );
function add_admin_menu_separator()
{
    add_menu_page( '', '', 'read', 'test', '', 'none', '10000000' );
}

Doing this creates a menu item without any text or icon, but it is still a link to /test. Using # won't work either because I don't want it clickable at all.

Is there any workaround for this?

Thank you!

  • I'm not sure that this is the same thing? – joq3 Mar 1 at 10:42
0

You may want to look at adding admin style and then targeting the menu:

function admin_style() {
  wp_enqueue_style('admin-styles', get_template_directory_uri().'/admin.css');
}
add_action('admin_enqueue_scripts', 'admin_style');

This is just an example:

#menu-comments:before {
   border-top: 1px solid red;
   content: "";
   display: block;
   margin-top: 10px;
   margin-bottom: 10px;
   width: 100%;
}

This adds a red divider above the "comments" menu, but adjust this to your own requirements.

  • The problem is that different user roles show different menu items. And this will change the look for different user roles because they might be missing this item or it will be in a different place. That's why I wanted to add another menu item which I could style. – joq3 Mar 1 at 10:42

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