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!
This question already has answers here: Add a Separator to the Admin Menu? (7 answers) Closed 6 years ago.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!
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.