Something like this should work from your functions file as long as you use the correct conditional tag for your CPT archive:
function exclude_single_post_cpt($query) {
if (is_post_type_archive('event') && $query->is_main_query() && !is_admin() ) {
$query->set('post__not_in', array(1646));
}
}
add_action('pre_get_posts', 'exclude_single_post_cpt');
Related Posts:
- is there a way to retrieve posts that do not have a featured image assigned?
- Wp-query causing problems with the_content();
- How to create posts (not post template) to be displayed on projects page?
- exclude custom post type by meta key in wp_query
- Quickest way to get last or oldest post date – WP Query
- Exclude the parent custom post-type posts only
- How do I create an archive page for standard posts?
- Why does using WP_Query inside a shortcode in an elementor page cause the arguments for WP_Query to get malformed?
- Loop on front-page.php
- WP_Query is printing out only one post when posts_per_page is set to multiple
- WordPress Orderby Numeric Value Not Working
- How to add post_type=value when editing that post type in the WordPress admin?
- Storing posts from query and accessing later via AJAX call
- Show custom post type filtered by category
- Get latest 3 posts from multiple CPT in one query
- Several post types on WP Query by tag and taxonomy
- Prioritize posts in query by meta keys?
- How to get all tags of a custom post type by id
- WP the_posts() on single-cars.php get category link
- Different Limit number of post on different archive page
- Custom post types and ‘new WP_Query’
- Variable not working in WP_Query
- WP_Query with custom post type ID
- Query within a foreach within a query (queryception)
- wordpress lists similar type of posts in a custom post type
- display posts of custom post type with custom taxonomy
- How to Query in WordPress which shows Alphabetic Posts?
- Exclude latest post from WP_Query taxonomy term loop
- How to query Posts from a custom post type which contains a custom taxonomy?
- Display post from custom post type
- list posts of two post types in a single template
- How to fetch posts that are stored in the different table than (default) wp_posts?
- Exclude a specific post in a Custom Post Type
- Display Parent-Child Posts in specific order by comparing IDs in array
- how to display posts content on the custom css popup by clicking on each title on the sidebar?
- wp_post_delete is deleting all offices
- SEARCH QUERIES – REVERSE OUTPUT
- How do I insert a custom post type query after a certain number of recent posts and then resume recent posts?
- minimize wp_query call to database
- subtracting the current post form then whole loop, which is generating all CPT titles
- post type => ‘any’ not applied my custom queries
- Custom Post By Category
- Custom post Query and WordPress Post Query Clash
- How to get the posts that my following users are liked?
- Get post from Category by Priority
- Most efficient way of showing children posts?
- Only show current category post
- How To Loop Through list with Custom Post Types
- Calling specific page with wp query
- How to display elements of different post types?
- Retrieving IDs of child pages which are in a different post type
- Query Posts From Multiple Post Types
- Change display wp post type to wp custom post type
- Dynamically change post_parent in every page load?
- How do I hide single category post on my post page
- Wp-theme Development
- show the most recent date of all posts to display on front end
- Sort ACF by custom taxonomy
- Restrict custom post type to only site administrator role
- Meta query with boolean true/false value
- How to force one column layout on custom post type edit page?
- Search multiple custom fields by using meta_query
- category__in not working on custom post type
- Date query for a custom meta field
- Set default option in dropdown of WP_Query?
- Display posts in random post types
- Custom WP_Query not returning results when querying custom post type
- Allow non-logged in users to see a future post after clicking on a list of future posts
- Update Post Meta for a logged in user
- Problem querying Custom post type by custom fields
- Get the category from custom post type
- Is it possible to store Custom Post Type data in separate set of tables and still have wp_post class functionality?
- can these 3 queries be re-written as 1 query?
- cannot override post_types in WP_Query()
- Wrapping x posts in html without leaving empty html
- Loop increase number
- Custom filter for main search: how to exclude specific post_type from search results
- Is This Code Efficient – Or is there a better way?
- Can’t change posts per page in WordPress Post Type Query
- Easy reading or transfer of data from posts?
- Creating a Tabbed Widget
- Using WP meta query to show custom post types by a start and finish date
- Invalid content when I try to import custom post type from the old template wordpress
- Display related CPT with custom taxonomy
- How to set post date in post_type so that it’s same as latest post in category
- build child and anchestor three from post parent
- Create a post automatically if search result has zero results
- Bulk trashing post ‘fails’
- WP_query sort by taxonomy
- Linking posts together with Advanced Custom Fields “both ways”
- Custom post type not being pulled in widget
- Query posts from multiple post types sorted by overarching menu order
- Custom Taxonomy Query by Taxonomny not working
- Linking custom taxonomies and posts
- Query posts by a type and another type only if post is in specific category
- Search page for custom post type
- how to pass args for archive.php query?
- Front end post or photo or both
- How to change post cpt with submit button?
- Storing every individual update to the posts being updated over time?