Skip to content

Instantly share code, notes, and snippets.

@maxxscho
Created February 7, 2015 09:30
Show Gist options
  • Save maxxscho/9e92bc8752957b0f8cec to your computer and use it in GitHub Desktop.
Save maxxscho/9e92bc8752957b0f8cec to your computer and use it in GitHub Desktop.
Wordpress Redirect Post Type archive
<?php
if ( ! function_exists( 'redirect_post_type_archive' ) ) {
/**
* Redirect to 404 if we are querying an post_type archive, we won't
* @author Markus Schober
*/
function redirect_post_type_archive() {
global $wp_query, $post;
if (is_post_type_archive(array('post-type'))) {
$wp_query->set_404();
}
}
add_action( 'template_redirect', 'redirect_post_type_archive' );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment