Skip to content

Instantly share code, notes, and snippets.

@thierrypigot
Last active November 23, 2017 09:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thierrypigot/5090de1caf0088baa2ee222088f3dac0 to your computer and use it in GitHub Desktop.
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
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