Support

Account

Home Forums Front-end Issues Display field on single product page

Unread

Display field on single product page

  • Hello, I have made a field to add to the Woocommerce attributes. I have added a picture below for more clearancy.

    explaination

    I am trying to display the field on the single product page. I have added the following code to the content-single-product.php template file.

    
    $terms = get_the_terms( $product->id, 'pa_merk');
    		var_dump($terms);
    		
    		$image = get_field('afbeelding_merk', $terms->taxonomy . '_' . $terms->slug);
    		
    		// Display the image if it exists
    		if ($image) {
    			echo '<img src="' . $image . '" />';
    		} else {
    			echo "<p>Foto niet gevonden.</p>";
    		}
    

    What am I doing wrong?

Viewing 1 post (of 1 total)

You must be logged in to reply to this topic.