1

Hello I would like to show my last product image as a thumbnail in specific category pages.

I would like to keep my general shop page displaying the first image as thumbnail but show the last one once I click on specific product categories.

I understand that the code should go in my functions.php inside the following if-statement

if (is_product_category(‘shirts’) ){
  //show last image for thumbnal
}
  • The system has a category image, just upload the image on each category, then query the image for current category. – Fernando Baltazar Nov 23 '17 at 21:55
  • Thank you Fernando, but Im not sure that will solve my issue. What I would like to show is each photo's last image from their 'product gallery' if the user is viewing a specific category page such as shirts (for example if Im in shirts I would like to show the last photo which is a silhouette of the product instead of the first which is the product with the model). What you are suggesting will show the same thumbnail for all the products sharing category? – Azzoni Nov 24 '17 at 10:38
  • Well your question is asking for an image product category not a product image; a category image covers all products sharing the same category. however is possible to get an specific image from post or product. Try using this where attachment ID is the number of your specific product image wordpress.stackexchange.com/questions/169475/… – Fernando Baltazar Nov 25 '17 at 20:43
  • I understand, I think my approach to the code is wrong, want I meant is If I'm in the page 'shirts' show me the last image for the product image gallery in all products, is the a way I could change to the last image in all products? – Azzoni Dec 1 '17 at 11:02
  • you need to play quering the images, I had the images using the examples with attachment ID but I never tried to load the last one. I think this can be solved with " 'order'= 'desc', 'post_per_page'=1 " – Fernando Baltazar Dec 1 '17 at 22:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.