You’ll have to create custom post meta for this, and add the code to display that custom meta in that function instead of a static text.
There are a lot of plugins out there that can help you do this, and most of them are free. Try using Advanced Custom Fields. That should do the trick for you.
Hope this helps!
Thanks. I think that put me on the right track…
I installed Advanced Custom Fields, created an image field and assigned it to a page/product. Then I went to the product edit screen and it allowed me to upload the image to that specific product.
But, I can’t figure out how to actually display the image on the product page. Will this be done via an action in functions.php or through PHP itself?
In the documentation (http://www.advancedcustomfields.com/resources/image/), all I see is php to render the image, but wouldn’t this put the same image on all pages?
I need something like…
If product = Banners then display image ‘banner_feedback’
Okay, getting even closer I think…
I found a snippet of code from someone who successfully added content to a single page using the following:
add_action( 'woocommerce_single_product_summary', 'woocommerce_template_top_category_desc', 1 );
function woocommerce_template_top_category_desc (){
$terms = get_the_terms( $post->ID, 'wc-attibute-class' );
if ( !empty($terms)) {
$term = array_pop($terms);
$text= get_field('txt-field', $term);
if (!empty($text)) {
echo $text;
}
}
}
Now I’m just trying to figure out how to modify it to display an image instead of a text field.
So far I have this, but it’s still not working.
add_action( 'woocommerce_product_thumbnails' , 'add_below_featured_image', 9 );
function add_below_featured_image() {
$terms = get_the_terms( $post->ID, '496' );
if ( !empty($terms)) {
$term = array_pop($terms);
$image = get_field('banner_feedback', $term);
if (!empty($image)) {
echo $image;
}
}
}
Figured it out. No need for Advanced Custom Fields after all.
add_action( 'woocommerce_product_thumbnails' , 'add_below_featured_image', 9 );
function add_below_featured_image() {
if( is_single( pageidhere ) ) {
echo '<br><img src="urlhere">';
}
}