There is not a NAND
operator for the tax_query
of WP_Query
. If I understood correctly, what you intend can be rewritten this way:
- Get all the posts without the term
c
. - Get all the posts without the term
java
. - Exclude the posts having both the terms
c
andjava
.
To achieve that, you can combine two NOT IN
queries and match them with an OR
:
$args = array(
'post_type' => 'book',
'tax_query' => array(
'relation' => 'OR',
array(
'taxonomy' => 'language',
'field' => 'slug',
'terms' => array( 'c' ),
'operator' => 'NOT IN',
),
array(
'taxonomy' => 'language',
'field' => 'slug',
'terms' => array( 'java' ),
'operator' => 'NOT IN',
),
)
);
$posts = get_posts( $args );
echo count( $posts );
Related Posts:
- Query/list all terms and their custom post count
- display post count in archive page that have relation with another taxonomy term
- Complex Custom Loop with Includes
- Display all posts in a custom post type, grouped by a custom taxonomy
- $wp_query->queried_object->ID throws warning: Undefined property
- The Operator “NOT IN” Does Not Work In tax_query
- Counting Posts of a Given Post Type Having a Specific Taxonomy?
- How to get_queried_object on multiple objects?
- Displaying Posts Related to Other Posts by a Taxonomy Term?
- How to get the parent’s taxonomy?
- Querying Posts by Taxonomy From Alternate Network Site
- Custom Post Type Category List & Post Count
- Help with hierarchical custom taxonomies and permalinks…almost there
- custom post type paging not working past page 3
- Should unaltered default loop/query return a list of custom posts belonging to a custom taxonomy?
- Taxonomy list. Order by a specific custom post type count
- Multiple Archive Pages for Custom Post Types AND Taxonomies
- Query for posts in 2 taxonomies
- Exclude current post when getting related post on custom post type and taxonomy
- Display Posts of a Category in Alphabetical Order (Custom Post Type)
- Ordering Custom Post Types with WP_Query
- Paginated Taxonomy Term Archive including one post per term
- Optimised Code for Pulling Taxonomy Posts
- WP_Query search posts by custom post type and custom taxonomy
- get_queried_object error How to show post count by month in the taxonomy page
- Is it possible to create a shortcode that will query a post based on taxonomies?
- wp_query to find posts by year and month
- Count posts with specific term_meta
- Custom Post Type Loop within Shortcode
- Fetch taxonomies by custom post type id array
- Taxonomy Archive: Display only one post per term from separate custom taxonomy
- Display CPT posts based on specific taxonomy
- shortcode to show custom post types by category
- Filtering WP_Query Dynamically on the Front-End
- Why get_posts() not returning only selected category posts from Custom Post Type?
- Archive for custom taxonomy lists all posts instead of current taxonomy
- Genesis filterable portfolio isotope [closed]
- Get custom taxonomies from multiple posts
- Return one unique custom post type result when it shares a custom taxonomy in WP_QUERY?
- WP_Query inside foreach loop returning same value for all options when filtered using ajax
- Post count by month of taxonmy term
- Custom WP Query on custom meta and sort by multiple meta keys value
- How can I made custom taxonomies relationship?
- Custom taxonomies relationship
- First custom field value (out of several) displayed twice after query
- Add Custom Post Type of specific Custom Taxonomy to regularly blog loop
- WP_Query orderby and tax_query
- Why is my WP_Query outputting my entries twice?
- How to display Related Posts based on number of taxonomy terms matched
- How to make WP_Query not to show irrelevant posts?
- WordPress wp_query() basic question about args
- Create an archive page for custom post type with custom taxonomy
- WP_Query() with custom post type and taxonomy — get all terms?
- Variable not working in WP_Query
- WP_query – Filter by tax_query and meta_query using multiple select
- Wp Query with multiple custom tag(taxonomy) by get the terms
- Custom post type, custom taxonomy, query posts only from taxonomy (children of)
- how to get this tax_query working?
- How to sort a WP_Query by a custom field AND ALSO filter by a different custom field
- I am trying to get cutom post cout by month of current taxonmy term
- How to get the post terms from a child taxonomy
- display posts of custom post type with custom taxonomy
- Custom post type and custom taxonomy 404 on page 2
- tax_query (if the terms are empty)
- Exclude latest post from WP_Query taxonomy term loop
- How to query Posts from a custom post type which contains a custom taxonomy?
- Get posts by category name
- WP_Query order custom post type with certain meta key value by post modified date
- Cant’ Display Custom Post Type Title Base on Tax Terms
- Loop for custom-post-type comparing taxonomy terms for “related” posts?
- Display featured posts for a custom post type by taxonomy
- Query for specific taxonomy that executes a particular loop depending on volume of posts?
- What is the most efficient way to execute recursive complex queries?
- set object terms after some some time of published post – functions.php
- Sort custom posts by date and then by taxonomy
- have to do a while have post to show for two custom post types sharing the same taxonomy?
- How to search through all child taxonomies using WP_Query?
- get_queried_object not work in taxonomy page
- WP_Query for custom taxonomies showing posts from non-specified terms?
- WP_query sort by taxonomy
- Custom Taxonomy – fields
- CPT Loop, include taxonomies and disclude others?
- Why get_posts() returns empty array while I am trying to get posts from some specific taxonomies and work properly with others?
- Displaying WordPress posts from post and custom post type in custom taxonomy
- Get posts of an specific term of a custom taxonomy
- Checking Taxonomy Terms for a Custom Post Type With get_the_terms Not Working
- Custom post type and custom taxonomies display
- WP_Query for CPT with filter by another WP_Query
- How to pass taxonomy terms to WP_Query along with $args?
- WordPress custom post type
- Loop with Custom Post Type and Taxonomies
- Custom Taxonomy Query by Taxonomny not working
- How to query posts by meta keys AND under specific category?
- Shortcode display CPT Query only showing 1 post?
- Storing/querying custom date data
- WP Query Post Type with same Taxonomy name
- Catergory args causing loop not to show
- Query custom post type and group by taxonomy
- WP Query – Can’t get posts with specific taxonomy
- Dynamically count the number of custom post types associated to a custom taxonomy