I'm currently using the taxonomy field in ACF, with the aim of printing the category name in the front end. Using it like so:
<?php $term = get_sub_field('category_selector'); if( $term ): ?>
<span><?php echo $term->name; ?></span>
<?php endif; ?>
Which is currently displaying nothing, I've debugged the $term
which doesn't display the category ID of 3
, but for some reason I can't get hold of the category name from this? Any suggestions would be greatly appreciated!
var_dump($term);
?ARRAY(1) { [0]=> INT(3) }
array(1) { [0]=> object(stdClass)#2150 (11) { ["term_id"]=> int(2) ["name"]=> string(16) "Product Category" ["slug"]=> string(16) "product-category" ["term_group"]=> int(0) ["term_taxonomy_id"]=> int(2) ["taxonomy"]=> string(21) "wpsc_product_category" ["description"]=> string(0) "" ["parent"]=> int(0) ["count"]=> int(2) ["object_id"]=> int(59) ["filter"]=> string(3) "raw" } }