register_post_type()
has quite a few related arguments, of which publicly_queryable
controls precisely what you are describing.
However note that it will completely kill the CPT on front end — individual posts, archives, even post previews.
If you want to do this conditionally you’ll have to manage this with code from scratch, which might get very involved to do comprehensively.
Related Posts:
- Adding /blog in front of single posts (only)
- redirect after submiting post for review
- Admin slow on Postlist (over 30k Posts in Database)
- Display all Categories except ones with a specific parent
- How to achieve a multi-taxomony layout with posts?
- What is the best way to set the post category (Custom Post Type) automatically based on the one of the tags assigned to the post?
- Settings -> Reading -> Posts Page ->Blog — is not working in my website
- Invalid content when I try to import custom post type from the old template wordpress
- Is it possible to get the specific content on the search page?
- Why is my custom post content only viewable when signed into WordPress?
- i need to have a tab with gategory post
- Custom Post type to Woocommerce Product type
- How to change Elementor Template for Single Page Post on Load
- Best way to fix bad count on All | Mine | Published
- How to mass get post editor URLs
- Get_post_custom not fetching value from array wordpress
- Add a form in every post and save data in post meta
- list articles in admin showing nested categories or slugs?
- Display Parent-Child Posts in specific order by comparing IDs in array
- How to create additional rendering for custom post types?
- open custom post type in popup window instead of page
- How we can create menu from Appearance > Menu and use as a add-submenu-page for admin menu?
- SELECT custom post type and its meta in SQL
- How to set post date in post_type so that it’s same as latest post in category
- Enforcing a rigid reusable template structure for similar posts?
- Search CPT by tag ids
- Post template with breadcrumb needs to show page navigated from
- Auto delete pages/posts without views
- Post category behave like a Post in back office menu
- Save data is post using php front end
- What is the best way to structure posts for the same event happening in different years?
- How to display custom field in product description?
- Right way to store a large set of similar information on website? [duplicate]
- How to display posts with plugin (advanced custom fields) field groups?
- Define multiple prefixes for custom post type
- WordPress – display relationship between blog posts and custom posts
- Create a post automatically if search result has zero results
- Post template not applying on theme (potentially rendering as Page template)
- Publishing failed. The response is not a valid JSON response
- add all blog posts to folder
- How do I find the count of the current post?
- Limiting the Number of User Posts to Their Own Posts
- Custom page with no headers, footers and its own CSS, Javascript
- Correct way adding External classes to Custom Post type and output their methods to template
- Permalink for specific post type
- how to display posts content on the custom css popup by clicking on each title on the sidebar?
- Show custom post status when logged out
- Show posts from WP Custom Post Type selected from a field in a metabox
- wp_post_delete is deleting all offices
- SEARCH QUERIES – REVERSE OUTPUT
- WordPress retrieving $post based on random key in $_POST
- order custom post type posts by custom date
- Is there a way to create a sidebar of bullets
- How do I insert a custom post type query after a certain number of recent posts and then resume recent posts?
- How to show posts of the same category on a page?
- Why doesn’t wp_delete_post allow trashing for custom types?
- Get queried object for custom post type count
- edit.php all post not working
- Assign a Post to a User
- Cannot save pages after migration
- Adding specific custom fields (images) to post excerpt
- Bulk trashing post ‘fails’
- $_POST from a Meta Box
- How to create editable sections in wordpress?
- show posts under custom post type with same autj
- Can WordPress show posts based on a button that the user clicked 2 pages back?
- How to make a non-public post on wordpress approval?
- How to change post cpt with submit button?
- How to automate the creation of advanced layout article/post
- How to get permalink of post based on post name?
- How Do I Add a Custom Post Type URL to Content?
- Storing every individual update to the posts being updated over time?
- Display code if title of the custom post matches title of other post
- Change post structure
- display posts, pages and custom post types from another wordpress site
- is therer any wordpress function to retrieve a specific html element from post content
- Post content in bootstrap modal
- Sort ACF by custom taxonomy
- Two pagination in one page without AJAX
- How to develop Knowledge center in WordPress Website
- Change post-name when inserting new Post if Specific Category is selected in WP
- Drawbacks of making the default post-type: post hierarchical [closed]
- I am having a problem with fetching product data in the Gutenberg block editor
- Post URL redirecting to homepage
- ACF – Tags not showing up in Custom Post Types
- Hide load more button if no more post in selected category
- Passing total post count to javascript
- Default post showing more than intended
- How can i show multiple post on single post wordpress, just like therichest.com or screenrant.com or hotcars.com.?
- Frontpage overriding my posts
- How to allow subscribers to create post of a new custom post type
- How to automatically update ACF field value every year?
- Display posts of only a certain category in WP Admin section?
- How to add a post page from a button without reloading
- Ajax load more post button not showing
- WP_Query for multiple post types just shows one
- Display the progress of post achievement with percentage against target in wordpress dashboard
- button onclick with get_post_permalink
- Adding a new custom post type using the editor causes 502 bad gateway error
- A developer set a ‘standard format’ for my blogposts on wordpress but i need to remove it, how?