Disable Post Format Archives
Redirects the automatic archives for post formats (such as /type/gallery/) to the homepage and removes them from the sitemap.
Opens WPIDE on
Code
add_action( 'template_redirect', function () {
if ( is_tax( 'post_format' ) ) {
wp_safe_redirect( home_url( '/' ), 301 );
exit;
}
} );
add_filter( 'wp_sitemaps_taxonomies', function ( $taxonomies ) {
unset( $taxonomies['post_format'] );
return $taxonomies;
} );
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.