Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

i have a custom post type name 'business' and taxonomy 'business-category'. now i want to show posts for some specific terms suppost, term1, term2, term3 etc. The following code is working for me but for only one term.

  $args=array(
    'taxonomy' => 'business-category',
    'term' => 'term1',
    'post_type' => 'business',
    'orderby'=> 'rand',
    );
  query_posts($args);

I need to pass array of terms. When i try to pass array of terms instead of one term it not working :(

   $args=array(
    'taxonomy' => 'business-category',
    'term' => array('term1', 'term2', 'term3'),
    'post_type' => 'business',
    'orderby'=> 'rand',
    );
  query_posts($args);

I also want to know how can i show post if i want to show from multiple taxonomy as well.

Thanks!


Resolved:

the query args will be:

    $args=array(
            'tax_query' => array(
                          array(
                                'taxonomy' => 'business-category',
                                'field' => 'slug',
                                'terms' => array( 'bars', 'restaurants' )
                           )
          );

Thanks!

share|improve this question
add comment

1 Answer

up vote 1 down vote accepted

I believe the array will work using terms, rather than term (plural)

http://codex.wordpress.org/Function_Reference/WP_Query#Taxonomy_Parameters

Has a lot of useful info for mutiple terms/multiple taxonomies

but basically look into the tax_query item, specifically AND or OR operators. It's all explained there pretty well

share|improve this answer
    
Thanks! get it working.. –  Sisir Apr 19 '11 at 14:01
    
Excellent, good job! –  Rev. Voodoo Apr 19 '11 at 15:37
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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