Complete the code to query posts with a specific taxonomy term.
<?php $args = [ 'post_type' => 'post', 'tax_query' => [ [ 'taxonomy' => 'category', 'field' => 'slug', 'terms' => '[1]' ] ] ]; $query = new WP_Query($args); ?>
The 'terms' key expects the slug of the taxonomy term you want to filter by. Here, 'news' is a valid category slug.
Complete the code to query posts where meta key 'price' is greater than 100.
<?php $args = [ 'post_type' => 'product', 'meta_query' => [ [ 'key' => 'price', 'value' => 100, 'compare' => '[1]', 'type' => 'NUMERIC' ] ] ]; $query = new WP_Query($args); ?>
The 'compare' operator '>' filters posts where the meta value is greater than 100.
Fix the error in the tax_query to filter posts with taxonomy 'genre' and term slug 'fiction'.
<?php $args = [ 'post_type' => 'book', 'tax_query' => [ [ 'taxonomy' => '[1]', 'field' => 'slug', 'terms' => 'fiction' ] ] ]; $query = new WP_Query($args); ?>
The taxonomy name must be 'genre' to match the taxonomy you want to query.
Fill both blanks to query posts with meta key 'rating' between 4 and 5.
<?php $args = [ 'post_type' => 'movie', 'meta_query' => [ [ 'key' => 'rating', 'value' => [[1], [2]], 'compare' => 'BETWEEN', 'type' => 'NUMERIC' ] ] ]; $query = new WP_Query($args); ?>
The 'value' array sets the range for the 'BETWEEN' comparison. Here, 4 and 5 define the rating range.
Fill all three blanks to query posts with taxonomy 'color' term 'blue' and meta key 'size' equal to 'large'.
<?php $args = [ 'post_type' => 'product', 'tax_query' => [ [ 'taxonomy' => '[1]', 'field' => '[2]', 'terms' => '[3]' ] ], 'meta_query' => [ [ 'key' => 'size', 'value' => 'large', 'compare' => '=' ] ] ]; $query = new WP_Query($args); ?>
The taxonomy is 'color', the field type is 'slug', and the term is 'blue' to filter posts correctly.