This has worked for me. Can you try it and replace the excluded ID by the id of post you want to exclude.
add_filter( 'pre_get_posts', 'exclude_specific_post_id' );
function exclude_specific_post_id( $query ) {
if ( $query->is_main_query() ) {
$query->set( 'post__not_in', array( 'YOUR_EXCLUDED_POST_ID_HERE' ) );
}
}
Related Posts:
- Add custom Attachment Display Setting for images
- Rewriting post slug before post save
- Removing filter dropdown in posts table (in this case Yoast SEO)
- Getting the post_id in wp_ajax function
- How to know if get_posts() failed?
- Show related posts by category but ignore one category
- Replacing all attachment links in post with media file link
- Change the default number of posts to show on mobile version
- Post content being duplicated by the_content();
- How can I pass $post object to ‘save_post’ add_action?
- Disable REST API for a user ROLE
- Insert posts in two tables
- How To Keep Posts from Being Displayed Two or More Times on My Homepage? [closed]
- custom wordpress post loop – hide iframe content
- Different template for posts of all subcategories of category
- Add custom field automatically (add_post_meta) with value based on number of words of article
- How to access featured image?
- Mark menu item as current-menu-item for category
- previewing my posts on static page?
- How to retrieve the postID in a “image_send_to_editor” hook function?
- Post revisions disappeared (for some posts)
- Replace ‘published on date’ with ‘modified on date’ on Posts
- How to display category from recent posts?
- Best way to assign post position in a news site homepage? (no categories, no sticky posts)
- How do I restart my loop with get_next_post()?
- “Duplicate” Posts Appearing Since 3.1.2 Update
- Rename “post” to “article” throughout the admin back end [duplicate]
- Set size for attachments
- Setup a custom dynamic post
- How to render arbitrary post without displaying it [closed]
- Need to remove duplication content on home page in wordpress theme
- How safe is renovating $wp_query when doing WP_Query pagination in Page Template
- Overwrite posts/pages via import
- Auto-realod with new posts // Ajax call
- how to get post order by post id wp_query?
- Is it possible to add/tick a category to a post when it is created?
- How many posts does the loop return?
- Posts loop displaying the same post data
- Display Posts on Custom Page
- How to display all posts divided/ordered by post date? [closed]
- Blog Post On Home Page Displaying Page Published Date Not Post Published Date
- Why I can not I use the variable outside my function?
- The_excerpt() doesn’t parse – how to change that?
- Can’t understand why sometimes a [caption] field appears
- Trying to edit archive.php to only show post extract, with featured image
- Divs appearing everywhere in post content
- Extracting relevant tags associated with that particular single post only
- Why in my query is display two title?
- Posts page not showing correct image
- Custom Articles page only showing a limited number of posts per page
- Custom posts listing widget always returns 1 extra result
- Post Title List on home page with time
- Automatic blog page with custom design [closed]
- Use posts_where to exclude posts ids from wp_query
- Get x recent posts by author?
- Short link to read complete post
- Delete all Tag Links from Posts
- Adjust the order for returned posts
- Post in bulk based on category template
- Automatic duplicate/copy of post to a related page in WordPress
- user_has_cap filter allows “edit_others_posts” but not is not allowing updating/publishing
- WordPress doesn’t save or publish new posts
- Yoast breadcrumb URL shows category instead of the page
- Add data attribute of post_id for Internal links
- Menu Items disappearing/being empty on save or post edit
- Display/Filter post using if else statement
- Foreach issue in get_posts function
- Contributor edits published post and sends for review – post is made private?
- Why does my “Add New Post” page have an old post in it?
- link to edit a post has empty target
- Nestling Posts Under Page & Justify Text
- Redirect to custom post if custom archive page has just one result?
- Adding posts updates previous post
- Strange behaviour in WordPress admin
- How do you update post date (year only) in a separate custom field?
- Is it possible to make a custom post that adds multiple pages?
- Creating a link to the first post in a category
- sometimes on saving a post as draft, it says Access Denied You don’t have permission to access “mywebsite.com/wp-admin/post.php”
- How do I change the post title’s link on the posts page?
- How do I make it so that new posts within a certain category go into a certain page?
- WordPress text field in array problem
- List Authors For Current Category
- Get query result according to merged array
- cleaning out posts that don’t exist anymore but links are still there
- Custom URL Structure for posts with subcategories
- Possible to display X number of authors posts from another WordPress site?
- Theme Unit testing not importing on MAMP server – Fatal error: Maximum execution time of 60 seconds exceeded
- Reading Setting Not Working for Number of Posts
- 404 for some custom taxonomy not ALL taxonomy
- Add tags to post before it’s created
- can’t post immediately
- List posts that are in the same category as the current post title
- save_post not working
- Password-protected Posts lead to 404 Error
- Multiple blog “feeds” in a single blog each with distinctly styled post pages
- How to get pagination working with “Pending” Posts
- Post’s arent displaying
- Show with echo if a post has two or more categories
- Site ‘Categories’: save an admin global setting with post metadata [closed]
- I cannot see the pagination in /wp-admin posts page