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
- WP_Query for multiple post types just shows one
- WP Query results showing posts outside of category ID
- Modifying the default post from wordpress
- tax_query (if the terms are empty)
- Custom post type to lead to single post type instead of shortcode modal
- Dynamic pages for linked categories and content
- Display custom post type for specific user
- Separate Content from gallery (custom post type)
- Restrict category access to specific users/groups. Author always has access
- Cannot get custom posts by category
- Modify Posts from Custom_Post_Type within the plugin
- Custom Post type loop with ACF not displaying properly
- Get all post from a post type
- Get post format
- How to add new post using a form to categories when categories are using as menu
- Custom wordpress loop
- How to set the mainpage of a custom post type?
- How to get Custom Post Type with Categories wise in WordPress using wp_query
- Shortcode with WP_Query more than once on one page
- Different post title, keywords and description
- Trying to add a class to post links
- Post Query not working
- displaying content of custom post type
- Can’t change posts per page in WordPress Post Type Query
- List latest post out of 2 custom post types
- how to get options to choose post format in add new post
- postsperpage value not being applied
- How do I edit the WordPress post.php file?
- Posts are not rendering perfectly [closed]
- Render a Post or Page using the correct file
- How to count other posts not having specific taxonomy terms?
- WordPress Count posts within a custom post type
- Create a WP_Query where if the first value of the first row is equal to the second compare other value
- How to filter url on post submission?
- How I can made a custom post type to page templates?
- Pagination for search results of custom post type [duplicate]
- Filter posts of custom post type by meta key in (List All Section)
- Group by custom field value (start and end times)
- Sort results without WP_QUERY?
- WP_Query get post from a category and from another post type
- Using Wp_Query, Json to add Highcharts series data
- Display the current post in browser as the first post in a loop (for a slideshow)