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;
}
}
Related Posts:
- How to detect single.php (but not single-portfolio.php)?
- Post type no single page
- Defined function isn’t showed on page
- Making a wordpress page print friendly
- Insert Shortcode exactly at the end of the content
- Show Next/Previous without Link
- How to change the case of all post titles to “Title Case”
- Function to execute when a post is moved to trash .
- Custom Single Post By Category
- Custom permalink structure only for default posts
- Fatal error: Call to undefined function post_exists()
- How to publish a post with empty title and empty content?
- How do I create a link that will always show the latest post?
- How do I use element instead of tags in WordPress post content having webP support?
- Code to auto expire posts after 30 days
- Post X of Y in single.php / sidebar.php
- Keep a fluid max number of posts on site
- Custom colors for post rows based on post meta value
- How to add an admin function only to posts, not pages?
- Human Time Diff, change mins to minutes
- Custom wp_trim_words() function not trimming right
- How to Display Post View Count
- Remove double space after a period
- custom single.php not working
- Delete Post From Front-End and attachment permanently
- Limit function to specific post category
- When paginating a Page with the tag, how can the 2nd and subsequent page styles be customised?
- Function to show random posts from a category
- Hiding posts in a list from specified categories
- Run a function when post is deleted?
- Checking is user author of number of posts?
- Add code just after Post content
- Pagination on single post page?
- Create cron job without a plugin?
- How to rename “Publish” metabox title in post screen
- Restrict post navigation to current sub menu
- Add icon/badge next to posttitle of specific category
- Converting a dynamic piece of code using WordPress Loop into a static one using Post ID
- Using wp_list_categories like the the_category (showing just current categories of a post)
- Exclude category from
- Show the content that is after the excerpt using child theme
- How to allow users to post only in certain category and hide elements from edit page?
- Can’t get buddypress notifications in front-end; why do I get this error?
- How do I display some posts fully on the homepage, and some as an excerpt only?
- Send post id through ajax and get the post content back
- Force authors to Preview a post before publishing
- Order posts alphabetically: how to set order=asc in mysql query?
- Insert sometext after first h3 in content
- Is it possible to customize the post according to post format in single.php?
- Change all author links in Blog roll
- Format latest/newest post differently
- is_page Funtion for Posts ?
- Adding a user’s ID behind the tag ref link address
- Isn’t the way posts are displayed very unefficient?
- How to check in functions.php if there is data in a WP_Query?
- restrict incrementation of post vies count when refreshing the page
- get_previous_post() while accounting for sticky posts
- Get post by tag
- Related Posts function not working
- the_content() Not Grabbing All Content
- Query function not executed between element [closed]
- saving/reading custom field value does not work – no value gets POSTed
- Internal linking to posts permalink fail because of spaces and stripe at postname
- Have h2 tag not show up if there are no blog posts
- WordPress as CMS: How to manage/handle images assigned to a post as full-sized background images in a slideshow?
- Can I style single post that are in multiple catergories?
- How to implement a WordPress comments function?
- How to add content above footer in posts from specific category
- WordPress – When visiting a `single post/ single.php` my category menu item link becomes active
- How to put the author of the post in the comments?
- How do I change the template specifically for single posts?
- Check if almost 10 year old – working code is up to date
- Show single post child category from a determined parent
- How to add a custom class attribute into code wrapper? [duplicate]
- Remove pagination if search returns empty
- Remove HTML tags from all posts
- Save All Post Permalink From A Specific Category into a .txt file
- AJAX load more posts not using correct category and repeating the same few posts
- How to Display Most View Post in the template file?
- display multiple posts and posts content on a single URL
- Show post excerpt
- How do I apply a wordpress function to something with no ID inside an archive page?
- Show author bio box
- How to correctly escape data
- Display author bio box
- Check if user has avatar
- Only show related posts when another post has same term
- Call image from post on index page?
- How do I get thumbnails?
- Run function after post is updated
- When Author add new post change default status to pending
- fire action when post is being edited as well as saved?
- Getting rid of the blog page entirely
- List direct children of page
- Notify Author of the post if admin deletes his post and perform some function
- Wrap div-tag around posts in page
- Ajax calls in wordpress
- No matching template found when using single.php
- how show post date for specific post?
- Filters do not work when there are multiple (one works)