简体   繁体   中英

wordpress plugin admin menu

I am trying to create a wordpress plugin admin menu. The problem that I am running into is with the menus. I am trying to add a page in the admin without actually adding the menu link. So for example I want to have a menu called test then I want to have some extra pages but I don't want physical links to them because they are only going to be used when there is an id to pass to them. is this possible and if so please someone explain because i can't seem to figure it out.

Yes. In your callback function for the admin page, just write out different sections and use conditional checks to display the right content. Then, under the page's title, add a <ul> with the class subsubsub containing the links to take the user to the right place. Something like this:

function my_awesome_admin_page(){
  echo '<h2>My Title</h2>';
  echo '<ul class="subsubsub"> <li><a href="?page=my-page">Foo</a></li> <li><a href="?page=my-page&foo=bar">Bar</a></li> </ul>';
  if($_GET['foo'] != 'bar'){
    //You're on the first page
  } else {
    //You're on the second page
  }
}

I forget what the class is to signify the current subpage, but you can take a look on the 'Add Plugin' admin page. I think it's selected .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM