WordPress.org

Ready to get started?Download WordPress

Forums

Excluding posts from a custom taxonomy (1 post)

  1. pealo86
    Member
    Posted 1 year ago #

    I need to query all posts from a custom post that doesn't have 'kit' applied to the taxonomy 'image-gallery'.

    I am using the following code but it returns no results:

    <?php
    	$query = array(
    		'post_type' => 'image-gallery',
    		'posts_per_page' => -1,
    		'tax_query' => array(
    			array(
    				'taxonomy' => 'image-gallery',
    				'field' => 'slug',
    				'terms' => 'kit',
    				'operator' => 'NOT IN'
    			)
    		)
    	)
    ?>

    Can anyone see what might be wrong with it?

Topic Closed

This topic has been closed to new replies.

About this Topic