How to show grandchildren taxonomy term only in Wordpress -
i have taxonomy called: locations.
locations go 4 levels deep:
united kingdom > england > london > wimbledon
we need output deepest taxonomy text on single post, outside of loop.
so reads: wimbledon
the code have far:
<?php global $wp_query; $terms_as_text = strip_tags( get_the_term_list( $wp_query->post->id, 'locations', '', ', ', '' ) ); echo $terms_as_text; ?> this outputs locations. need show deepest.
can help? thanks
use get_terms insted, las value of array.
$terms = get_terms('locations', array('orderby' => 'none')); echo end($terms); or if need terms inside current post use get_the_terms function:
$terms = get_the_terms( $post->id, 'locations' ); echo end($terms);
Comments
Post a Comment