As explained in Codex
post__not_in
(array) – use post ids. Specify post NOT to retrieve.
post__not_in
argument have to be passed as array.
Change your query to:
$the_query = new WP_Query( array(
'category__in' => $project_category,
'posts_per_page' => -1,
'post__not_in' => array( $postid ),
) );
And it should work.
Related Posts:
- Some doubts about how the main query and the custom query works in this custom theme?
- WP_Query vs get_posts
- Order posts by ID in the given order
- Get the number of posts from the current page results
- WordPress Custom Query to show posts from last x years
- Query Custom Meta Value with Increment
- How to query ‘posts_per_page’ to display a different blog posts index template?
- 2 loops on page – one with orderby rand second orderby date
- Query posts by specific word on title
- Five posts from a category in footer
- WP_Query condition affects posts_per_page count
- Some doubts about how the main query and the custom query works in this custom theme?
- How do I rewrite this loop as a new WP_Query style-loop?
- Include current post into loop
- How to provide meta_key array to wp_query?
- get_posts output always same post
- How to create custom query by keyword in post title?
- How to make posts unqueryable/unpublish posts where ACF relationship field is an unpublished post? [closed]
- Conditional operator OR not working with custom fields
- Get posts that do not have the same tags as current
- Should I reset $wp_query?
- 2 queries with counters
- Paginate pages with dynamic query
- Performance concerns: index.php vs taxonomy-$taxonomy.php
- Determine if ID is page or post and query the ID
- Custom template for password protected page
- Magazine style frontpage with multiple categories/loops and no duplicate posts
- Duplice post with standard WP loop – fixed by using query_posts() instead
- How do I stop the same post showing multiple times in a archive?
- Custom query for custom post type not getting correct post ID
- Problem with my loops
- WordPress For Loop Prints Unwanted Extra Paragraph Element
- How to order posts, that have already been filtered by custom taxonomy, by their category names?
- How to add in WP_Query to every 3 posts displayed? [duplicate]
- query_posts() doesn’t seem to be called in my page
- Some doubts about how the main query and the custom query works in this custom theme?
- Ordering Posts by parent category, name ascending
- Converting an existing query_posts to WP_Query
- Multiple loop for “featured” items returns wrong posts
- Show number of posts AND number on current page (cannot make it work)
- Resetting post data to previous loop in nested loops
- Pagination returns 404 after page 20
- Make loop display posts by alphabetical order
- get custom post type by tag
- How to know which one is the main query?
- Group posts by custom field
- get_posts() seemingly ignoring post_type
- Woocommerce custom loop to show all the products [closed]
- How to show the posts of some category first, and then all other
- Pagination stops at page 6
- Paginated HTML Sitemap
- Why does the_content not work like others for a set post id?
- How to limit total number of posts in wp query loop?
- Pagination is broken and I need help fixing it
- How to vary post loop results layout and resume?
- Get a post from other loop each n-posts in the main loop
- Where is the WP_Query instance instantiated (when working with themes)?
- Serve specific “template” page at any URL that ends in its slug
- Show post number in widget loop
- how to make members list directory through wordpress post custom meta key.
- Loop Performance > JSON files vs. WP_Query vs. REST API
- Search form not working with custom query?
- WordPress ignoring LIMIT / posts_per_page despite being in wp_query
- Conflict with get_posts and the_content
- How to get all post except particular category without breaking the paging
- Filter Custom Taxonomy Posts
- Order post type by sum of two custom fields
- Use WP_Query or query_posts() or get_posts() for optimizing a site?
- Meta query compare for ID’s greater than specific ID
- WP_Query with one category in args shows other categories
- Ordering posts by custom field and grouped by month
- relation OR instead of AND – Filtered term ID’s in loop
- Compare “Main” post ID to ID inside wp_query loop
- filter posts by meta key with pagination
- Why does apply_filters behave different inside and outside a loop?
- WP_Query Class custom field parameters
- Elementor posts custom query based on tag [closed]
- How can I do a orderby by the number of items? So basically list by starting with the array with the largest number of post
- Function the_posts_pagination() not compatible with WP_Query arguments
- Prevent Duplicate Post Counted by Query
- How to show specify category template for both parent and child category
- Pagination inside the blog page not working
- How to query most recent post for each author?
- Custom Query Pagination not working on static front page
- How to search CPTs in draft using get_page_by_title()
- query all posts published by certain user id
- modifying the loop multiple times with arguments passed through ajax to wp_query
- WP_Query causing links to not work
- Retrieving category pages from subcategory returns empty sets
- Iterate through ID’s in loop
- Loop through multiple custom fields with increasing number
- Different number of posts showing in development vs production server
- How to organize a WP_Query’s list of posts by category and display category title?
- query post based on comparison
- Pull Instagram images into an existing loop?
- Pagination in custom query not working [duplicate]
- query_posts problem – need help
- How to write a query-function as a query-shortcode?
- First post outside of loop, homepage only?
- Woocommerce set loop_shop_columns to be 3 in the main shop page loop only and 4 otherwise