1

I want know, How to disable single post view in wp. any plugin or setting???

Is there a way to disable single post page, for example when some tries to go to single post page to show not found or 404 page.

1 Answer 1

3

You can add to the end of theme's header.php file this:

if( is_single() ) {
  global $wp_query;
  $wp_query->set_404();
  status_header( 404 );
  get_template_part( '404' );
  exit();
}

Note that the get_template_part( '404' ) function needs 404.php file in your theme directory.

1
  • Note: For addressing all post types, in particular page and attachment too, use is_singular(). Commented May 1, 2015 at 13:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.