0

I'm using the following WP_Query arguments array:

$args = array(  'post_type' => POST_TYPE,
                            'tax_query' => array(
                                'taxonomy' => TAX,
                                'field' => 'slug',
                                'terms' => TERM
                            ),
                            'posts_per_page' => 2
                        );

The problem is this query displays all the posts from POST_TYPE which have a TAX (any TAX) assigned to them but it's not limiting it to the TERM (particularly one term) taxonomy!
I just want the posts from the specific TERM taxonomy and nothing more!

1 Answer 1

3

You're one array short. The tax_query is an array of arrays.

$args = array(  'post_type' => POST_TYPE,
                'tax_query' => array( 
                     array (
                      'taxonomy' => TAX,
                      'field' => 'slug',
                      'terms' => TERM
                     ), 
                 ),
                'posts_per_page' => 2
             );

See http://ottopress.com/2010/wordpress-3-1-advanced-taxonomy-queries/ for more.

1
  • Thanks Otto, I didn't know it MUST be an array of arrays. You helped me a lot here.
    – 2hamed
    Jun 8, 2012 at 16:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.