I have been tasked with creating a custom taxonomy (‘sector’) for a custom post type (‘case_study’), on a WordPress site that already uses ACF.
Everywhere online tells me that to get the field (an image specifically, called ‘sector_image’), to use get_field, and to get it for a custom taxonomy, use the tax name before the Term ID in the second parameter, like so:
$image = get_field('sector_image', 'sector-'.$sector->term_id);
I can confirm that $sector->term_id
returns the term ID of the current term (looping through a get_terms object), but I don’t get anything returned, even when I print the $image var.
edit: damn, figured it out myself.
Okay well as per usual I figured it out just as I posted it, it turns out, unlike many places I saw listed, the second parameter of
get_field
requires the taxonomy slug and the term ID to be seperated by an underscore, not a hyphen or no seperator at all as listed by lots of answers online, not sure if the usage has changed at some point in the past, but yes, this works: