Problem with get_posts, tax_query and counting the number of posts

Try this again removing operator and relation arguments as follows: here is a useful link http://ottopress.com/2010/wordpress-3-1-advanced-taxonomy-queries/

$products = get_posts(array(
    'post_type' => 'products',
    'posts_per_page' => -1,
    'post_status' => 'publish',
    'tax_query' => array(
        array(
            'taxonomy' => 'collection',
            'field' => 'slug',
            'terms' => array($current_collection)
        ),
        array(
            'taxonomy' => 'type',
            'field' => 'slug',
            'terms' => array($current_type)
        ),
        array(
            'taxonomy' => 'color',
            'field' => 'slug',
            'terms' => array($current_type)
        )
    )   
));
$countpost = count($products);

Leave a Comment