Created
January 23, 2017 13:13
-
-
Save AlkarE/b2264941491cee5209790ce8c07edf4b to your computer and use it in GitHub Desktop.
Disable cpt 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
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 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
How to disable a custom post type archive page but enable its feed.