Quantcast
Channel: Hot Weekly Questions - Web Applications Stack Exchange
Viewing all articles
Browse latest Browse all 9786

Understanding the 'AND' Operator in WordPress WP_Query's tax_query [closed]

$
0
0

WP_Query is a very rich object but sometimes confusing.
I want to know if these syntaxes mean exactly the same thing: bringing posts that belong on the same time to both categories 76 and 78 (intersection, not 'OR').

1/ Syntax 1

$wp_query = new WP_Query(array('post_type' => 'post','tax_query' => array('relation' => 'AND',        array('taxonomy' => 'category','field' => 'id','terms' => array(78),'operator' => 'IN',        ),        array('taxonomy' => 'category','field' => 'id','terms' => array(76),'operator' => 'IN',        ),    ),));

2/ Syntax 2

$wp_query = new WP_Query(array('post_type' => 'post','tax_query' => array(        array('taxonomy' => 'category','field' => 'id','terms' => array(76, 78),'operator' => 'AND',        ),    ),));

3/ Syntax 3

$wp_query = new WP_Query(array('post_type' => 'post','category__and' => array(76, 78)));

Viewing all articles
Browse latest Browse all 9786

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>