Disable single pages and archives and keep preview

You can redirect, when someone tries to see the archive or the single of your custom post type, just redirect them to another page, just put this in your functions.php

add_action( 'template_redirect', 'theme_redirects', 99 );

function theme_redirects() {
    if ( is_post_type_archive( 'post_type_slug' ) || is_singular( 'post_type_slug' ) ) {
     wp_redirect( 'my_url' );
         die();
  }
}

See references:

is_post_type_archive

is_singular

template_redirect

Leave a Comment