Still learning my way around WordPress and ACF, and I need some help.
I have a custom taxonomy (location) and an acf single select field (listing_priv_location) for the custom taxonomy.
Taxonomy is as follows:
Location A
— Home
— Office
Location B
— Mall
— Movie Theatre
If I select “Movie Theater”, I can get it to display correctly using the following:
<?php
$leveltwo = get_term( get_field( 'listing_priv_location' ), 'location' );
echo $leveltwo->name;
?>
Which outputs: Movie Theatre
How can I display it such that it will automatically add the first level taxonomy:
Output: Movie Theatre, Location B
Thanks.
<?php
$leveltwo = get_term( get_field( 'listing_priv_location' ), 'location' );
echo $leveltwo->name;
$term = get_term($leveltwo->parent, $leveltwo->taxonomy);
echo ', ',$term->name;
?>