• Hello! I’d love some help with this. =)

    I’d love to remove the parent terms of a custom taxonomy from displaying on posts.

    Currently it displays, Parent, Parent 2, Child but I would only like to display the Child.

    What is the correct php for doing so?

    I found this code, but I don’t know how to modify it to only show the final child.

    <?php
    
    $terms = get_the_terms( $post->ID, 'From' );
    if ( !empty( $terms ) ) {
        $output = array();
        foreach ( $terms as $term ){
            if( 0 != $term->parent )
                $output[] = '<a href="' . get_term_link( $term ) .'">' . $term->name . '</a>';
        }
    
        if( count( $output ) )
            echo '<p><b>' . __('Categories:','om_theme') . '</b> ' . join( ", ", $output ) . '</p>';
    }
    ?>
  • The topic ‘Display Child Taxonomy on Posts without Parent’ is closed to new replies.