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

This is from the codex.

<?php get_term_by( $field, $value, $taxonomy, $output, $filter ) ?>

Suppose I have a taxonomy system as follows;

taxonomy: "healthy foods" and it's a hierarchical taxonomy and your hierarchy goes exactly like this;

healthy foods
        red ones
        green ones
        red ones
        green ones

and you use the get_term_by function as follows;

get_term_by("name","red ones","healthy foods")

Do you get the veggies or the fruits?

share|improve this question
up vote 2 down vote accepted

get_term_by() just returns the first matching term, 'first' meaning some internal order in MySQL.

If having multiple terms with the same name matters in your case, don't rely on get_term_by() alone.

share|improve this answer
Thanks Scribu. I'm glad you are hanging out here. Tell me please, if this site, or the stackoverflow site or the wp-hackers list is a better place to ask wordpress questions... I got myself into a huge wordpress project and I just don't have the proper shoes for it yet. So, I'm gonna need lots of help. – Average Joe Apr 7 '12 at 17:37
@AverageJoe this is absolutely the community for WordPress questions, I constantly am on here learning new things just from questions I read through. You'll figure it out, I'm sure. – David Apr 7 '12 at 17:46

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.