I use this function and hook:
function mysite_admin_menu()
{
add_menu_page( 'Categories', 'Catégories', 'administrator', 'categories', 'a_function' );
add_submenu_page( 'categories', 'Manage', 'Manage', 'administrator', 'xxx', 'a_function' );
remove_submenu_page('categories','categories');
}
add_action( 'admin_menu', 'mysite_admin_menu' );
It displays what I need: a menu with a submenu on the left admin menu bar.
The thing is, the submenu leads to this page: admin.php?page=xxx
.
How can I do to link to a URL like edit-tags.php?taxonomy=category
?
If I swap the slug in the add_submenu_page
with a relative URL, the link will lead to
admin.php?page=edit-tags.php?taxonomy=category
.
Whatever I do, I always get admin.php?page=...
which is not what I want.
This is an old post but can’t you just use wordpress
$menu
and/or$submenu
globals like Oleg suggested in number 2.When in doubt copy WordPress:
wordpress/wp-admin/menu.php
For example to add link this seems like it would work:
You can replace the
$permalink = ...
with anythingSo this should also work :
Also, it’s suggested not to use ‘administrator’ (even though I use it as well. Anyway, read this ticket for alternative solutions.
I don’t recommend you do that.
Let’s assume your prefix for
admin.php
is_trigger_me_
Submenu
Main Menu
I call both examples as “hacks”. They possible to do, but better to not do that.
update.
if case if satisfied with redirection =)
in case if you want to substitute this by taxonomy page (
edit-tags.php
)If your submenu is missing the
admin.php?page=
prefix, you should register the parent menu first, then the submenu.Otherwise the link will be just the slug.
Thank you Oleg, your script works but breaks the admin interface (background colors and images all dissappear for any reason).
But if I have to take this road, I can do this instead:
It’s seems curious to me that there is no simple way to link a submenu to any url.
This kind of redirection is messy…but it works.
Although this is an old problem, I’d like to contribute for consideration this code:
it uses javascript redirect instead of creating another add_action to redirect via http.