Tuan_H
(Tuan H)
1
$post_id = get_the_ID();
// get the assigned taxonomy terms for "property-city"
$assigned_terms = wp_get_post_terms($post_id, 'property-city', array("fields" => "all"));
// loop through the term objects
foreach($assigned_terms as $term){
// display child term name
echo 'Child term:'.$term->name.'<br>';
// display parent term name
if($term->parent != 0){
$parent = get_term_by( 'id', $term->parent , 'property-city' );
echo 'Parent term:'.$parent->name.'<br>';
}
}