WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have made a multiple category. Each item belong to one or more category. So when display one item, i like to retreive the category of this item, and display all post that have belong to that category.

Example. Chair : cat = sit, leather, one person

So when display the chair, i like below to display all item that have : sit leather and one person as category

Is there a plugsin that do that ?, or in php it's simple to do ?

share|improve this question
up vote 1 down vote accepted
# according to your example:
$categories = array ( 'sit', 'leather', 'one person'  );

# get all id's by the category names
foreach ($categories as $category_name) {
$category = get_term_by( 'name', $category_name , 'category' ); 
$ids[] = $category->term_id;

# get all posts for the categories
query_posts( 'cat='.join(',',$ids) );

Sorry, I cannot test it right now, this is just a guess till tomorrow.

share|improve this answer
And I think using $categories = get_the_category(); in the first line would get the categories of the post, if you want to do it that way – Rev. Voodoo Apr 1 '11 at 13:15

Your Answer


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.