Home > Blockchain >  Add an admin menu to wordpress without link
Add an admin menu to wordpress without link

Time:06-02

I want to add a menu to the wordpress admin with an ID, that is, without a link. I want to add it to activate a modal/popup that I will add. I can place a floating button, but I want to have it all more organized.

Here's how to create the menu: https://developer.wordpress.org/reference/functions/add_menu_page/

What I don't know is how to make it just have an icon, name, and ID, with no redirect link.

CodePudding user response:

You can hook into the global $menu like so

add_action( 'admin_menu' , 'admin_menu_custom_menu' );
function admin_menu_custom_menu() {
    global $menu;
    $menu[20] = array( 'Menu item name', 'manage_options' , 'http://example.com', '', 'classname', '', 'dashicons name or link to image' ); 
}

Just make sure that there $menu[20] doesn't exist or it will overwrite it.

  • Related