Have a look at https://codex.wordpress.org/Class_Reference/WP_Query, and maybe try passing your args in an array.
Above page lists this exact example, which should work:
// This WILL work $exclude_ids = array( 1, 2, 3 ); $query = new WP_Query( array( 'post__not_in' => $exclude_ids ) );
Related Posts:
- How to set post expiration date and time and move the page to archive after expiration [closed]
- Loop doesn’t exclude the specified category in home page
- How to get post with slug and exclude categories
- Exclude post category in a blog page
- Excluding category from post navigation in WordPress?
- Exclude a ‘portfolio’ custom category?
- Different post sort order within different categories
- Skipping first 3 posts in wp query
- How to add metabox for post of specific category
- Manipulate post category after time
- How to get Category Id from Post Id ?
- Categories box not showing on post edit pages
- Exclude ALL posts from sub categories
- List only child categories a post is in, of a specific parent category
- Add custom field to all posts in specific category
- Exclude category on blog list page
- is there a better way of combining this?
- wp_list_categories link to first post of category instead of calling taxonomy template
- WordPress Child Category Display All Posts
- How to Add ‘Post Categories’ to the Dashboard Sidebar
- How only display all post related to category
- Add category to all post by using sql query?
- Display posts in alphabetical order for a particular category
- Full Width Main Post
- How to automatically apply a category based on the post title?
- Direct link to “New post” in specific category?
- Using permalinks, category slugs, and tag slugs
- How do I retrieve then print the currently viewed sub categories?
- Pulling in post category and children within category
- Post categories to pages
- Get attachments for posts that belongs to a specific category
- WP_Query: Mixing category__in and tag__in together
- If in_category not working for multiple single.php pages
- How can I setup a relationship using categories in WordPress?
- How can I hide tags on a child-category page, if that tag has not been used?
- Display post category in foreach loop
- Single.php – Get Current Parent Category
- How do I stop the loop from repeating in my category template?
- Is it possible to add/tick a category to a post when it is created?
- How show categories in admin and get that selected to show posts in index
- if in category but only with post meta
- singular posts using archive styling
- Display selected categories onto post page
- Un-highlight Blog Menu Item when Category Menu Item is Selected
- Show posts on front page only
- Change the background of each post according to the category
- Programmatically add posts from specific category to menu
- Post is in descendant category not working in home.php
- How to get posts ordered by using their categories?
- Get post category as a separate string and url
- Display Related Posts by Category in Random
- How to show category based post in home page?
- How to show beneath posts the full category path?
- How to view all posts (on site, not admin) that are uncategorized?
- How to create a list of links to post with specific category
- Display Current Posts Category (with the most posts)?
- Post meta not working
- ACF date picker to trigger category change
- get category in list of posts // shortcode for custom related posts
- Get category slug of the Parent category of a Product
- Featured Story Shortcode not outputting content
- exclude particular category in api
- How to add a ‘News’ section to specific posts in WordPress
- Get Category in save_post Hook
- How to make a page show posts only from specific categories without editing php files
- How to show category image if no featured image is set?
- How to show posts ordered by random [duplicate]
- How to run select query of post with category and tags?
- Display new posts categories in separated divs
- Add Categories To Custom Post
- Query posts from newest category
- Point users to a specific url directory for some posts
- Display Posts by Categories
- Static text above category page
- Ajax – Post Categories and Load More
- Edit Posts Page but not category specific pages?
- Show only top 3 posts from 3 categories in order on home page
- Hide categories from showing above a Post
- How to organise post by category and date
- Show post if in category
- How to display custom content in post with category XXX
- Order posts by separate menu order for different sub-categories
- Displaying categories items among posts
- Delete old post with new post
- I need to create a page or post hierarchy
- Separate categories parents, childs and grandchilds in dropdowns
- Display ONLY Latest Post From Several Categories
- Exclude sub sub categories from displaying in the archive page
- Show all posts in category
- Taxonomy Category category.php not working
- Change from all posts to specific categories post on main page?
- Polylang – display one post into 3 categories with different lang [closed]
- How to sort the post to a specific category
- hide particular category post from front page only [closed]
- View post with specific category id and name which I selected in the backend (drop-down option)
- Site ‘Categories’: save an admin global setting with post metadata [closed]
- How can I fixe the article title problem?
- Automatically select category based on user role
- Show category name in category.php when posts assigned to multiple categories
- Adding content to the top of post’s based on their category