Disable Tag Archives
Redirects tag archive pages to the homepage and removes tags from the XML sitemap, for sites that use tags only internally.
Opens WPIDE on
Code
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 add this snippet
- Install WPIDE on your WordPress site (it is free) and open Code Snippets.
- Use snippet above adds it from the library in one click. Or copy the code into a new snippet with the same code type.
- It is added inactive: review the code and settings, then switch it on.