Reputation: 37
Initial disclaimer, I have scoured SO and Google for ways to do this, extensively and exhaustively, to no avail. Please don't post links to other questions, I have already tried them all.
I've reduced the problem to a concept, to see if it's even possible to achieve in a sensible manner.
So this is my problem. A WooCommerce product has:
What I'd like to achieve:
See attached images for a more visual idea. Essentially I'd like to have conditional featured images & a product gallery without featured images in the loop.
How would I go about doing that? Thank you so much in advance.
Edit 1: I managed to write the code for the gallery without the featured images:
<?php
global $product;
$product_id=$product->id;
$attachment_ids = $product->get_gallery_attachment_ids();
foreach( $attachment_ids as $attachment_id ) {
// Display the image URL
echo $Original_image_url = wp_get_attachment_url( $attachment_id );
// Display Image instead of URL
echo wp_get_attachment_image($attachment_id, 'full');
}
?>
So now all I need is conditional featured images based on the page ID?
Upvotes: 1
Views: 1053
Reputation: 37
Ended up using Advanced Custom Fields for the separate featured images, all I need now is to conditionally show them based on page ID.
Upvotes: 0