So I have a custom type called "vendors" and two custom taxonomies for it. One is "state" and the other is "type".

I am trying to list all the vendors from a certain state on one page. I'm using the file called "taxonomy-state.php" which works perfectly. It displays all the vendors in the state.

Now what I want to do is specify the types of vendors in order. So the page will look something like this:

Vendors in "STATE":

Vendor Type #1: Vendor #1 Vendor #2 Vendor #3

Vendor Type #2: Vendor #1 Vendor #2 Vendor #3

I got it to display vendors by state. But I need to display them in the above layout.

I have an idea of how to do it. But I need to be able to make a query that can get a vendor from a certain state and certain vendor type.

Thanks in advanced,


2 Answers 2


Hopefully someone else will flesh out this answer, I don't have the time to write out a full solution right now...

If you're using WordPress 3.1, look at the tax_query parameter that you can pass to query_posts. It can handle multiple taxonomies and relationships between them.

Otto's post WordPress 3.1: Advanced Taxonomy Queries is the best explanation I've seen of what tax queries can do, and how to use them...

In older versions of WP, you're stuck using a plugin like this one, or rolling your own fairly complex SQL queries.

  • 1
    I think this answer is quite complete. Use plugin linked or wait for 3.1 pretty much covers it.
    – Rarst
    Dec 31, 2010 at 9:32
  • Thank you so much. I decided to install 3.1 RC1 and do this. The plugin wasn't working out for me. Hopefully they launch the version soon. I don't want to leave the client with an unstable version.
    – criticerz
    Dec 31, 2010 at 18:47
  • Go for it. RC1 is already very stable and it sounds like the official release will be in a matter of weeks, if not sooner. Dec 31, 2010 at 19:01

For wp 3.0.x am using this function:

function posts_search ($post_type,$taxonomies) { // $taxonomies should be an array ('taxonomy'=>'term', 'taxonomy2'=>'term2')
foreach ($taxonomies as $key=>$value) {
    unset($ids); $ids=array();
    foreach($posts=get_posts($args) as $post) { $ids[]=$post->ID; }
    if (empty($ids)) return false;
return $posts;


and here's an exemple:

$posts = posts_search ('produtos',array('taxo1'=> 'term-aa','taxo2'=>'term-bb')); if($posts) { foreach($posts as $post) { ...

Allows me to query posts with two taxonomies parameters. If it can help.

Fyi, the function is not from me.

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.