1
votes

I am registering the submenu page like so:

function MYPLUGIN_submenu_fn(){
  add_submenu_page(
  'books-home', //parent slug
  'edit book', //page title
  ' Edit Book', //menu title
  'manage_options', //capability
  'edit-book', //slug
  'MYPLUGIN_submenu_fn_callback',//callable function
  'dashicons-location-alt' //icon url


  );
}

//callback function
MYPLUGIN_submenu_fn_callback(){
  include("edit_book.php");
}

// I register the submen
add_action('admin_menu','MYPLUGIN_submenu_fn');

The I can link to edit_book.php like so:

<a href="<?php echo admin_url('admin.php?page=edit-book&id='.$book->id);?>">

This works just fine. My problem is; I don't want the edit book menu title on the books menu. I registered the menu just to use its slug internally. So I removed the title name from the menu function so that it does not appear on the books menu like so:

function MYPLUGIN_submenu_fn(){
  add_submenu_page(
  'books-home', //parent slug
  'edit book', //page title
  '', //menu title text deleted
  'manage_options', //capability
  'edit-book', //slug
  'MYPLUGIN_submenu_fn_callback',//callable function
  'dashicons-location-alt' //icon url


  );
}

Though the submenu looks blank, but its still there. When I click on it despite being blank it just works. I have no doubt this is not the right way to do it. My question, is there away you can register a url in wordpress plugin without necessarily registering a menu or a submenu? Or is there a better way I can hide the submenu so that it cannot appear to end users but still use its slug internally to link pages in my plugin? Please Help.

1

1 Answers

0
votes

If You replace parent slug parameter with empty string it will register page but not show in menu structure.