Skip to content

Instantly share code, notes, and snippets.

@AlkarE
Created January 23, 2017 13:13
Show Gist options
  • Save AlkarE/b2264941491cee5209790ce8c07edf4b to your computer and use it in GitHub Desktop.
Save AlkarE/b2264941491cee5209790ce8c07edf4b to your computer and use it in GitHub Desktop.
Disable cpt archive
function disable_cpt_archive_template(){
if ( is_post_type_archive('cpt') ) {
global $wp_query;
$wp_query->set_404();
status_header( 404 );
get_template_part( 404 ); exit();
}
}
add_filter( 'archive_template', 'disable_cpt_archive_template', -1 );
@AlkarE
Copy link
Author

AlkarE commented Jan 23, 2017

How to disable a custom post type archive page but enable its feed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment