I’m simply trying to upload a product image for each product on the “Edit Product” page on the WordPress backend. However, there is no place to upload a product image. How do I get the product image upload area to show up in WordPress?
I have tried editing the single-product.php file but I don’t really know where to start. I also tried adding a custom field to product page types which allowed me to create an area where product images can be added, but they don’t show up in the actual place where product images are supposed to go.
I’m assuming the reason the ability to add product images is not available is because of some conflict with my custom theme. However, I cannot change themes. I am able to edit the current theme, but I just don’t know how to go about fixing this problem
Update: I temporarily changed the theme and the ability to add a product image became available. But, when I changed it back to my custom theme, that ability went away. Any ideas of what in my custom theme could be causing this?
Advertisement
Answer
If it is working if you choose another theme, it could be the case that the product image is the “featured image” in wordpress. With the featured image, you can set an image to your wordpress posts. Articles are just posts with a custom post type.
It could be possible, that your theme has not activated the featured image feature. You can do this by adding this line of code to the end of your functions.php of your theme:
add_theme_support( 'post-thumbnails' );
If this makes not show up the possiblity to add an image to a product, it could be a problem with the editor. Have you tried changing vom gutenberg to classic editor? Just to make sure, it is not a editor problem.
EDIT:
If you want to show your featured image in the product single page, you can do this with
<?php the_post_thumbnail(); ?>