I have a project where we have registered a custom taxonomy called "product-category" and have an Advanced Custom Field linked to it called "range_image".

We then have a custom page template (not a category.php or archive.php) page where we are displaying a list of categories and its associated data. All data is displaying perfectly however we cannot pull in the range_image?

Here is the code for pulling in the product-category data:


$ranges = get_terms( 'product-category', array(
    'orderby'    => 'count',
    'parent'     => 1,
    'hide_empty' => 0,

    $counter = 0;
   foreach ($ranges as $range): 

We can then fetch normal fields like this:

<?php echo $range->name ;?>

Can anyone offer a solution on how we would fetch the ACF field range_image off this query?

All examples we can find reference the following code but it doesnt work:

<?php $image = get_image('range_image', $range->term_taxonomy_id);
echo '<img src="'.$image['url'].'" alt="'.$image['alt'].'" />';

Any help would be appreciated!

Thanks Stan

1 Answer 1


For fields associated with taxonomy terms, you must specify the term taxonomy along with the term id. In your case, the following would work:

$term = 'product-category_'.$range->term_taxonomy_id;
$image = get_field('range_image', $term);

Documentation: http://www.advancedcustomfields.com/resources/get-values-from-a-taxonomy-term/

Not the answer you're looking for? Browse other questions tagged or ask your own question.