I am trying to create a wordpress plugin admin menu. The problem 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 dont 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 becuase i cant seem to figure it out.
+1
A:
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
.
John P Bloch
2010-07-02 13:59:39
Thanks for the reply but I was looking for something where you could add the pages. For example my links would be ?page=page_1 or page=page_2. Is this possible?
ngreenwood6
2010-07-02 14:24:00
No, unfortunately not. It has to be registered as a page in the menu to do it that way. I don't know how you were implementing this, but you might be interested in registering the page as a new top-level menu item and then your new pages as submenu items of that new top-level menu. They go over it here:http://codex.wordpress.org/Adding_Administration_MenusBut that would still give physical links to the submenu items.
John P Bloch
2010-07-02 14:29:48
ngreenwood6
2010-07-02 14:39:45
What you could do is just have the pages redirect to the correct page if they haven't set up the prerequisites.
John P Bloch
2010-07-02 16:00:04