Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 'tax_query' => array(
- array(
- 'taxonomy' => 'city',
- 'field' => 'slug',
- 'terms' => array( nyc, boston, london ),
- )
- )
- // get all terms in the taxonomy
- $terms = get_terms( 'city' );
- // convert array of term objects to array of term IDs
- $term_ids = wp_list_pluck( $terms, 'term_id' );
- // proceed with tax query
- $args = array ('tax_query' => array(
- array(
- 'taxonomy' => 'city',
- 'field' => 'term_id',
- 'terms' => $term_ids,
- )
- )
- );
- $city_posts = new WP_Query( $args );
- $args = array ('tax_query' =>
- array(
- array(
- 'taxonomy' => 'city',
- //'field' => 'term_id', // <-- not needed, default
- //'terms' => $term_ids, // <-- not needed
- 'operator' => 'XXX' // Use a non-existing operator
- )
Add Comment
Please, Sign In to add comment