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 an using two taxonomies with private posts.

  1. category e.g. massage, travel
  2. location e.g. new-york-city, boston etc.

On a location page, I want to show categories that are relevant to that location. e.g. If I am on ?location=boston page I would find all the posts that are in boston, then I would find a list of categories in which these posts are categorized. I want this list to be displayed on top of location page.

Is there is a simple, built-in way to do all this?

share|improve this question
    
You mean, when you're on Boston page, you want to get massage or travel, whatever is available in Boston? –  Rutwick Gangurde May 3 '12 at 5:33
    
Yes. e.g. if boston has on 'massage' deals, it should show only 'massage' category. If it has 'travel' deals too then it should show 'travel' category too. –  afnrf May 3 '12 at 6:29

1 Answer 1

up vote 1 down vote accepted

In the_loop, just add this code...

<?php
    $cats = wp_get_object_terms(get_the_id(), 'category');
?>

Print_r $cats, it will have the list of the categories applied to this post.

share|improve this answer

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.