Saturday, 25 May 2013

wp query with multiple taxonomy?

wp query with multiple taxonomy?

Hello I want to get all the posts that belong to multiple taxonomies. I saw on codex but it is having only static(2) taxonomies but in my case I have variable number of taxonomies.
On Codex website this is the code...
$args = array(
    'post_type' => 'post',
    'tax_query' => array(
        'relation' => 'AND',
        array(
            'taxonomy' => 'movie_genre',
            'field' => 'slug',
            'terms' => array( 'action', 'comedy' )
        ),
        array(
            'taxonomy' => 'actor',
            'field' => 'id',
            'terms' => array( 103, 115, 206 ),
            'operator' => 'NOT IN'
        )
    )
);
$query = new WP_Query( $args );
but taxonomies can be more than 2 or can be just 1. So How to loop for variable number of taxonomies.
I want like this http://software.pricegrabber.com/office-suites/p/169/
Please help!!

No comments:

Post a Comment