Skip to content

Instantly share code, notes, and snippets.

@chrdesigner
Last active January 4, 2016 23:57
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 chrdesigner/dd65f8674d8631844962 to your computer and use it in GitHub Desktop.
Save chrdesigner/dd65f8674d8631844962 to your computer and use it in GitHub Desktop.
Set a custom post type to not show up on the frontend - WordPress
<?php
function chr_redirect_post_type() {
global $wp_query;
if ( is_post_type_archive('sliders') || is_singular('sliders') ) :
$url = get_bloginfo('url');
wp_redirect( esc_url_raw( $url ), 301 );
exit();
endif;
}
add_action ( 'template_redirect', 'chr_redirect_post_type', 1);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment