$conf, $runtime; function_exists('chdir') AND chdir(APP_PATH); $r = 'mysql' == $conf['cache']['type'] ? website_set('runtime', $runtime) : cache_set('runtime', $runtime); } function runtime_truncate() { global $conf; 'mysql' == $conf['cache']['type'] ? website_set('runtime', '') : cache_delete('runtime'); } register_shutdown_function('runtime_save'); ?>customization - Add a menu item to admin dashboard which isn't a link?|Programmer puzzle solving
最新消息:Welcome to the puzzle paradise for programmers! Here, a well-designed puzzle awaits you. From code logic puzzles to algorithmic challenges, each level is closely centered on the programmer's expertise and skills. Whether you're a novice programmer or an experienced tech guru, you'll find your own challenges on this site. In the process of solving puzzles, you can not only exercise your thinking skills, but also deepen your understanding and application of programming knowledge. Come to start this puzzle journey full of wisdom and challenges, with many programmers to compete with each other and show your programming wisdom! Translated with DeepL.com (free version)

customization - Add a menu item to admin dashboard which isn't a link?

matteradmin9PV0评论
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!

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!

Share Improve this question asked Mar 1, 2019 at 10:11 joq3joq3 3813 silver badges21 bronze badges 1
  • I'm not sure that this is the same thing? – joq3 Commented Mar 1, 2019 at 10:42
Add a comment  | 

1 Answer 1

Reset to default 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.

Post a comment

comment list (0)

  1. No comments so far