Created
February 7, 2015 09:30
-
-
Save maxxscho/9e92bc8752957b0f8cec to your computer and use it in GitHub Desktop.
Wordpress Redirect Post Type archive
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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