Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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?

share|improve this question

2 Answers 2

Do a simple redirect:

if ( CONDITION_SEE_BELOW )
{
    wp_redirect( admin_url( 'edit.php?post_type=YOUR_CPT', is_ssl() ? 'https' : 'http' ); );
    // faster then die();
    exit;
}

I tried to take the whole pages thing apart and wrote a table to sum them up and get definitive hints about where you currently are in this paste.

To list them here:

  1. global $menunot possible
  2. global $submenuslug edit-tags.php?taxonomy=YOUR_TAX
  3. global $current_screenid edit-YOUR_TAX 1)
  4. global $selfedit-tags.php 1) 2)
  5. $GLOBALS['$_SERVER']['REQUEST_URI']edit-tags.php?taxonomy=YOUR_TAX 1)

1) Be sure to also check…

if ( edit.php?post_type=YOUR_CPT === $GLOBALS['current_screen']['parent_file'] )

…in case your tax is registered elsewhere too.

2) This will only help if a) you're that you ain't got another tax registered or b) if you want to redirect them all.

share|improve this answer
    
+1 Just posted almost the same answer :D. Below is what I've used. Good shout on checking post type in case it is registered for multiple post types - this wasn't an issue for me, but could cause others headaches... –  Stephen Harris Mar 8 '12 at 16:44
up vote 0 down vote accepted

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.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.