ACF: Getting Images attached to a Taxonomy

In this example, your ACF field is named ‘associated_image’ and ‘chosen-image-size’ is the desired image size that is set within your theme.

// Get particular category's object info.
$queried_object = get_queried_object();

// (Optional depending on desired outcome) If you wanted to get the type of taxonomy.
$taxonomy = $queried_object->taxonomy;

// (Optional depending on desired outcome) If you wanted to get the associated ID.
$term_id = $queried_object->term_id;

// Get image ID for this field.
$attachment_id = get_field( 'associated_image', $queried_object );

// URL of image at specific size.
$image = $attachment_id['sizes']['chosen-image-size']; 
Additional reading:

Leave a Reply

Your email address will not be published.