# Disable Tag Archives

> Redirects tag archive pages to the homepage and removes tags from the XML sitemap, for sites that use tags only internally.

- Type: PHP
- Runs: Run everywhere
- Category: [Archives](https://wpide.com/library/category/archive/)
- Tags: tags, archives, redirect
- Author: WPIDE Team
- Installs: 0
- Updated: 2026-10-28
- Page: https://wpide.com/library/disable-tag-archives/

## Code

```php
add_action( 'template_redirect', function () {
    if ( is_tag() ) {
        wp_safe_redirect( home_url( '/' ), 301 );
        exit;
    }
} );

add_filter( 'wp_sitemaps_taxonomies', function ( $taxonomies ) {
    unset( $taxonomies['post_tag'] );

    return $taxonomies;
} );
```

## Notes

Your theme may still print tag links on posts; they will redirect to the homepage.

## How to use it

Install the free WPIDE plugin (https://wordpress.org/plugins/wpide/), find "Disable Tag Archives" in its snippet library and add it in one click; or create a new PHP snippet in WPIDE (or any code snippets plugin) and paste the code above. More snippets: https://wpide.com/library/
