Disable single post page

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

Related posts

Leave a Reply

1 comment

  1. Although I’m also curious as to why you’d want to do this, and would probably suggest using a custom post type instead, this would probably work (actually works for any single post type except pages and attachments):

    add_action( 'pre_get_posts', 'wpse44983_single_post_404' );
    function wpse44983_single_post_404( $query ) {
        if ( $query->is_main_query() && $query->is_single() ) {
            $query->is_404 = true;
         }
    }