Forums

How do I get the child of a taxonomy term? (2 posts)

  1. estevancarlos
    Member
    Posted 3 months ago #

    I'm using this, which pulls the parent and the child:

    <?php
    // Get terms for post
    $terms = get_the_terms( $post->ID , 'subject' );
    // Loop over each item since it's an array
    foreach( $terms as $term ) {
    // Print the name method from $term which is an OBJECT
    print $term->name . ' . ';
    // Get rid of the other data stored in the object, since it's not needed
    unset($term);
    }
    ?>

    Is there some way to modify this code to only retrieve the child or a better way to do this?

  2. estevancarlos
    Member
    Posted 3 months ago #

    Any ideas?

Reply

You must log in to post.

About this Topic

Tags