If you want a custom admin page for a taxonomy, you can set 'show_ui' => false
when you register it to suppress the default admin page and then create a new admin page to replace it.
However edit-tags.php?taxonomy=taxonomy-slug
still takes you to the ‘hidden’ default admin page. Is there way of directing it instead to the custom admin page. Or otherwise is there another method than circumvents this issue?
Not sure why I didn’t think of this earlier. I suppose I was hoping for a way to ‘hijack’ the default page to display something else… Anyway following my original method:
If you want a custom admin page for a taxonomy, you can set ‘show_ui’ => false when you register it to suppress the default admin page and then create a new admin page to replace it.
You can get round the issue of edit-tags.php?taxonomy=taxonomy-slug
taking you to the hidden taxonomy page, by simply redirecting the user to your page, using wp_redirect
:
add_action('load-edit-tags.php','myprefix_redirect_to_custompage');
function myprefix_redirect_to_custompage(){
$screen = get_current_screen();
if($screen->id == 'edit-mytax'){
$url = admin_url('edit.php?page=mypage');
wp_redirect($url);
exit;
}
}
Assuming mytax
is the taxonomy name. $url
should be the url of the custom page replacing the default taxonomy page.