Disable Date Archives
Makes yearly, monthly and daily archive pages return a 404, which avoids thin duplicate pages on most sites.
Opens WPIDE on
Code
add_action( 'template_redirect', function () {
global $wp_query;
if ( is_date() ) {
$wp_query->set_404();
status_header( 404 );
nocache_headers();
}
} );
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.