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 a small isuue, this code retrive me the parent categories from a post type.

The post_type is : serial The taxonomy is : seriale

$terms = get_terms('seriale','child_of=668');foreach ($terms as $term) {echo '<a href="'.get_term_link($term).'">'.$term->name.'</a>';}

The problem is: after i added another post in my site it my theme it aprear on all duplicate.

EX: First post - i select Year 2011 Second post - i select Year 2012

In archive it retrive me for the first and second post...

:2011,2012 ...

I want to be able to get only wath i select... I want to get categories only for child_of=668

Wath im doing rong. Thanks

share|improve this question

get_terms retrieves all terms in a taxonomy, not terms added to a post.

you want to use get_the_terms to retrieve terms assigned to a specific post. there are no additional arguments to filter the list of terms returned, you'll have to manually check a term's parent to only output terms that are a child of a specific term id.

$terms = get_the_terms( $post->ID, 'seriale' );
foreach( $terms as $term ):
    if( 668 == $term->parent ){
        echo $term->name;
share|improve this answer
thanks it works – Batman Feb 4 '13 at 0:59

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.