You cannot use the same object of WP_Query
twice. Therefore you need to create another one with a tax_query
parameter to fetch posts which are not assigned to any term.
//fetch all reviews which have no assigned term in 'review-product'
$taxonomy = 'review-product';
$post_type="reviews";
$args = [
'post_type' => $post_type,
'tax_query' => [
[
'taxonomy' => $taxonomy,
'terms' => get_terms( $taxonomy, [ 'fields' => 'ids' ] ),
'operator' => 'NOT IN'
]
]
];
$query = new \WP_Query( $args );
The idea is to fetch a list of all terms of your taxonomy and pass them as argument to your tax-query with the NOT IN
operator.
The second loop in your example should walk over the new WP_Query
object.
Related Posts:
- WordPress query with items from more than one selfdefined taxonomy as `term` argument
- Check if a post has term inside loop
- display ACF repater field in archive page
- Display posts the match taxonomy term linked from wp_list_categoies?
- List taxonomy terms plus their latest post ordered by post date
- Get array of current post term ID’s
- Function get_queried_object() return NULL in custom taxonomy
- Querying on multiple taxonomies pulled from $_GET checkbox array not working?
- List custom taxonomy terms sharing posts with a term from a second custom taxonomy
- How to Filter Posts by Custom Fields?
- How to order posts by title after they have already been sorted by category
- Search form not working with custom query?
- Post loop for all taxonomy terms
- Custom taxonomy.php not working
- Filter Custom Taxonomy Posts
- How to add custom meta to ‘pre_get_terms’?
- get term id from term name
- WP_Query to output chosen term and posts with no term assigned
- WP Job Manager plugin – Listing only the twelve job categories on frontpage order by jobs they have
- How to print term name inside wp post loop
- Query Taxonomy By Page Title
- Query for specific taxonomy that executes a particular loop depending on volume of posts?
- 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
- How do I stop the same post showing multiple times in a archive?
- Get categories within specific term
- How to define a custom hierarchy for terms?
- Custom loop – Isolating post meta output depending on current query taxonomy terms
- tax_query not working properly with get_posts
- taxonomy-{term}.php terms pagination returning 404 after a certain page
- Need help with Query Loop. Need to get current taxonomy term and its posts and group them by a different selected taxonomy term
- WP_Query to show post from a category OR custom field – Not 100% answered
- Get newest value of an array
- Add a custom variable to query page object
- WP_Query a custom field value bringing back 0 results
- Filter custom post type by custom taxomony
- Set Transient on CPT
- How to pass taxonomy terms to WP_Query along with $args?
- Issue in If else condition [closed]
- Create multiple sections for all categories and then queries all the posts for each of those categories
- Pagination not working with WP_QUERY
- Show posts in category
- Hiding all posts/products/pages from a site based on a custom taxonomy/domain name
- Both WP_Query and get_posts returning 1 post
- Loop with Custom Post Type and Taxonomies
- Custom search (wp query by custom fields)
- Iterate through ID’s in loop
- How to get several fields from wp_query?
- Sorting is not working in WordPress WP_Query
- Add custom WP_Query after the first 3 posts
- Load 3 posts in flexslider slide [closed]
- Loop through multiple custom fields with increasing number
- Query pages by child term
- WP_Query for attachments without duplicating post_parent and displaying tagged image
- Different number of posts showing in development vs production server
- Issue with WP_Query (need a array of selected ID’s)
- How do I display posts with specific value in a custom field into my loop?
- Page displaying 1st post from a range of custom tax?
- List ALL posts within last week from current category on category page
- WordPress WP_Query Array Custom search via taxonomies
- Post data in separate divs with incrementing class using WP_Query
- An archive page without post format (just standard post)
- Custom post type archive organized by category
- Limit the number of posts from a specific category on index.php
- wp_query display posts based on day
- Multiple wp_query loops showing first 5 posts on all pages instead of older posts[Resolved]
- Sorting Posts Based On Meta Value Using AJAX
- Next / previous posts link doesn’t show up with Posts 2 Posts
- How to exclude posts ordered by comment_count from subsequent wordpress loops using WP_Query?
- Order by multiple meta keys on wordpress
- Order posts with custom taxonomy array
- No content found on page 2 of pagination with 1 post per page
- meta_query dates from an array
- Creating array to compare custom field values
- wp_query pagination links producing 404
- Converting an existing query_posts to WP_Query
- loop through custom post types with meta data
- Custom Taxonomy + JQuery Tabs
- Display First posts without the default featured image
- Pull Instagram images into an existing loop?
- Loop being strainge
- Using Query In Post Type Archives
- Multiple loop for “featured” items returns wrong posts
- $query conflicting with other queries in the same page
- How ‘secure’ are loops?
- Pagination in custom query not working [duplicate]
- Multiple loops on index page with sticky post and pagination
- Catergory args causing loop not to show
- Pagination problem with multiple loops on the same page
- Problem with WP_Query sort
- How to Get The Taxonomy Term in Custom Post Type Loop Inside a Wp Query
- query_posts problem – need help
- WordPress Post Looping? [duplicate]
- How to do a loop inside a loop?
- Carousel Loop only duplicating
- Remove 5 latest posts from the loop
- Exclude post formats in custom loop
- display custom post type from register taxonomy
- Get author meta data with no published posts in author.php?
- Query for page content, and query for posts on the same page?
- Can’t seem to get an else statement correct? [closed]