I have a custom hierarchical taxonomy ('location') that looks like:
Tokyo
--Minato
----Roppongi
I have a post where only "Roppongi" is selected and I want to display as text only the top level parent term of the taxonomy (Tokyo) without any category link.
<?php $myterms = get_terms( array( 'taxonomy' => 'location', 'parent' => 0 ) );?>
The above code gives me...
Array ( [0] => WP_Term Object ( [term_id] => 11 [name] => Tokyo [slug] => tokyo [term_group] => 0 [term_taxonomy_id] => 11 [taxonomy] => location [description] => [parent] => 0 [count] => 0 [filter] => raw ) )
... as an output if I use...
<?php print_r($myterms);?>
... to display the result at the front-end. How do I display only the [name] value in the array? I tried the below code but get an error.
<?php echo $myterms[0]['name'];?>