Instantly share code, notes, and snippets.

Embed
What would you like to do?
Disable Date Based Archives
<?php
// This will redirect all date based archive to a page that does not exist,
// effectively disabling them, with a 404 error code
add_action( 'template_redirect', 'pu01_date_archive_not_found' );
function pu01_date_archive_not_found() {
if ( is_date() ) {
wp_redirect( get_home_url() . '/date-archive-not-found', 301 );
exit;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment