I have an Image field called Banner Image
The field displays in product category pages (for the taxonomy term product_cat)
The field returns the image ID
This is how I display the field:
$img = get_field('banner_image');
if ($img) {
echo $img;
}
The field does display on front end but only in parent category pages, not in sub-categories
How do I fix that?
When getting fields from categories and other taxonomies you need to suppl the post ID. See this https://www.advancedcustomfields.com/resources/get-values-from-a-taxonomy-term/
Works like a charm, thanks so much!
Here’s the solution if it helps anyone:
$img = get_field('banner_image', 'category_' . get_queried_object()->term_id);
if ($img) {
echo $img;
}