ACF pro template help

Hi there,

I’m trying to modify my shop template, so that I can list certain icons for each tag.
I installed ACF pro and created a custom_image for product_tag

it is called: tag_taxonomy_image

I managed to create a loop which checks for a certain tag (right now it’s 1EUR) and echos if it is found.

I’m trying to output the image associated with this product_tag, but I can’t. I’m trying to follow this document: https://www.advancedcustomfields.com/resources/image/

I’m modifying the content-product-php, and here’s my code currently:

<?php
/* Get the product tag */
$terms = get_the_terms( $post->ID, 'product_tag' );


$product_tag_check = array();
if ( ! empty( $terms ) && ! is_wp_error( $terms ) ){
    foreach ( $terms as $term ) {
        $product_tag_check[] = $term->name;
    }
}

/* Check if it is existing in the array to output some value */

$image = get_field('tag_taxonomy_image'); //'tag_taxonomy_image' is our field name
$size = 'thumbnail'; // (thumbnail, medium, large, full or custom size)


if(in_array('1EUR',$product_tag_check)) {
	echo '1EUR tag exists';
	echo $image['url'];
	echo wp_get_attachment_image( $image, $size );
	

?>


<?php   } else { 
   echo '1EUR tag does not exist';
   }


   ?>

Could you nudge me in the right direction?

Hi there,

I managed to fix this with if statements. Not pretty. But it works.
Anyway, I’m trying to add ACF text_fields to my templates, but It does not display. Only way I found is adding it via hooks, but it does not lend itself to easy layout customization. What is the right way to add an ACF field to a given template?

Hello @Pbalazs89,

Thanks for writing in!

To add ACF in your site, please check out this detailed video tutorial:

Please do not forget to check out our other videos too!

Subscribe to our channel for more updates, tips and how to videos.

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.