ngreenwood6
ngreenwood6

Reputation: 8216

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.

Upvotes: 0

Views: 1363

Answers (1)

John P Bloch
John P Bloch

Reputation: 4581

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.

Upvotes: 1

Related Questions