WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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 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
up vote 1 down vote accepted

In the_loop, just add this code...

    $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


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.