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!
Assuming that
3
is a category ID…In other words, it looks like ACF is just storing the ID, not the whole object, so you need to use that ID to grab the category object before you have access to the name, slug, etc.