Can you simply choose the same image for the category thumbnail and for the featured image of all the products in that category?
Thanks for responding.
Yes, but I do not want to have to go to each product and select the image.
What I’m looking for is a way to automatically display the category image as the product featured image
A product could be in multiple categories. What logic would determine which category image was used for a given product?
Hi Lorro
In this particular case the product is in only one category.
J
Try this script at your own risk:
http://pastebin.com/XLfUXxvq
Hi Lorro
Thanks so much for the time you spent on this.
I’ve run the script and it works 🙂
Is there a way to set it up so that it runs on it’s own rather than through the shortcode? My aim is to have all products adopt their Category image on creation.
For your info:
Even though the featured image was updated as expected, there was an error message on 2 of the products:
Warning: Invalid argument supplied for foreach() in /home/stillpoi/public_html/members/wp-content/themes/responsive-mobile-child/functions.php on line 186
Post ID: 97 Product category name: Recreational
Product featured image set to category image.
Warning: Invalid argument supplied for foreach() in /home/stillpoi/public_html/members/wp-content/themes/responsive-mobile-child/functions.php on line 186
Post ID: 100 Product category name: Recreational
Product featured image set to category image.
Any thoughts?
Thanks once again
John
Sorry I am unable to find a way to hook it into the save product action. Anyway, it would then be impossible to update featured images after changing the category image without visiting each product in turn, which is not what we want with this problem.
I am unable to find the cause of the foreach error, but I have added some extra error checking which may expose the error in a more meaningful way.
I have added an “all” option for the cat name if you want to do all product categories in one run.
http://pastebin.com/XLfUXxvq
Hi Lorro
Thanks again for all your work on this.
I’ll have a further look at the error messages and see if I can work out what the problem is.
If I find out I’ll post the answer here.
I’ll use it as is for the moment and look for ways to integrate it
I really appreciate what you’ve done for me
Kindest Regards
John