Skip to content

Instantly share code, notes, and snippets.

@wplit
Created March 10, 2021 03:50
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wplit/5523941c7b5a77b993bb9c3b595eb6d4 to your computer and use it in GitHub Desktop.
Save wplit/5523941c7b5a77b993bb9c3b595eb6d4 to your computer and use it in GitHub Desktop.
output woocommerce gallery images. (inside product builder inside a code block)
<?php
global $product;
$image_size = 'medium'; /* Image size */
$attachment_ids = $product->get_gallery_image_ids();
foreach( $attachment_ids as $attachment_id ) {
$image_url = wp_get_attachment_image_src( $attachment_id, $image_size )[0];
echo '<img src="' . $image_url . '" class="cell">'; /* Needs cell class to be used inside carousel */
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment