Answer the question
In order to leave comments, you need to log in
How to display Woocommerce product gallery?
Good day. Tell me a php script that displays a WooCommerce product gallery. I added 3 photos and I need to display exactly 3 photos, without any attributes that the wokomerz itself creates. I've searched all over the Internet, I've been looking for half a day. There's no such thing. If it displays, it displays pictures as links, a bunch of divs, 200 classes of pieces. I don’t need it like that. Just display 3 pictures that I added to the gallery, I will define them myself in my own script. Thank you!
The screenshot shows that a bunch of garbage displays
Answer the question
In order to leave comments, you need to log in
Something like this
global $product;
$attachment_ids = $product->get_gallery_image_ids();
foreach ( $attachment_ids as $attachment_id ) {
$full_src = wp_get_attachment_image_src( $attachment_id, 'full' );
echo "<img src='" .full_src[0] ."'>
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question