Skip to content

Instantly share code, notes, and snippets.

@jeffsebring
Created July 29, 2013 04:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jeffsebring/6102096 to your computer and use it in GitHub Desktop.
Save jeffsebring/6102096 to your computer and use it in GitHub Desktop.
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