Last active
November 23, 2017 09:55
-
-
Save thierrypigot/5090de1caf0088baa2ee222088f3dac0 to your computer and use it in GitHub Desktop.
Set a custom post type to not show up on the front end
This file contains 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
Besoin de support WordPress ou de maintenance WordPress ? | |
Contactez WP Assistance : https://www.wp-assistance.fr | |
<?php | |
add_action( 'template_redirect', 'wearewp_template_redirect', 1); | |
function wearewp_template_redirect() { | |
global $wp_query; | |
// redirect CPT_NAME_HERE CPT to home page | |
if ( is_archive('CPT_NAME_HERE') || is_singular('CPT_NAME_HERE') ) { | |
$url = get_bloginfo('url'); | |
wp_redirect( esc_url_raw( $url ), 301 ); | |
exit(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment