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

1 Answer 1


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;

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.