Home / Blog / WordPress
,

How to disable taxonomy archives in WordPress?

First published 26 Jan 2018. Tested again in November 2026 on WordPress 7.1.4 and PHP 8.4.

WordPress taxonomy provides flexibility in setting its properties while registering it. To disable WordPress taxonomy archives, set “public” as “false” as shown in below example code. This will remove “View” action link from taxonomy screen and also redirect the user to website homepage when trying to access the URL of a taxonomy manually.

1. Via register_taxonomy() arguments (best for custom taxonomies)

When registering a custom taxonomy, set ‘publicly_queryable‘ and ‘rewrite‘ to false:

register_taxonomy( 'your_taxonomy', 'post', [
    'public'             => false,
    'publicly_queryable' => false,
    'rewrite'            => false,
    'show_ui'            => true, // keep UI in admin if needed
] );

2. Redirect archive requests to 404 (for built-in or existing taxonomies)

Add this to your theme’s functions.php or a plugin:

add_action( 'template_redirect', function() {
    if ( is_tax( 'your_taxonomy' ) ) {
        global $wp_query;
        $wp_query->set_404();
        status_header( 404 );
        nocache_headers();
    }
} );

View or fork this snippet on GitHub Gist.

For category or tag archives specifically, replace is_tax() with is_category() or is_tag().

Need this done on a live site? Exivon Tech takes on projects and audits, led by me.

Dhiren Patel

Principal Full-Stack Engineer · Founder, Exivon Tech

I’ve built and run enterprise web platforms and e-commerce for 13 years, and I built ShieldScope, a free WordPress security scanner, and Lede, a free block theme.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.