@bounty_digital, sure, but I’m afraid you’ll have to use the Display Posts Shortcode addon for that. Below is a snippet you could tweak to your liking. The code should go in your functions.php or in a custom plugin, and will append a carousel with product gallery images to the post content:
add_filter( 'the_content', 'wpbc_woo_the_content', 10, 1 );
function wpbc_woo_the_content( $content )
{
if( ! is_singular( 'product' ) )
return $content;
global $product;
$wpbc_attachment_ids = $product->get_gallery_attachment_ids();
if( $wpbc_attachment_ids )
{
$wpbc_attachment_ids = implode( ',', $wpbc_attachment_ids );
$content = $content . do_shortcode( '[display-posts post_type="attachment" id="' . $wpbc_attachment_ids . '" bootstrap="1" unwrap="1"]' );
}
return $content;
}
As to your second question, a simple unwrap="1" should do the trick. However, you might be experiencing a problem similar to this one.
Hey! Thanks for your quick reply. Unfortunately it’s not working for me. It doesnt output the carousel. It just prints the shortcode. π
You’ll need to install the Display Posts Shortcode plugin: https://wordpress.org/plugins/display-posts-shortcode/
Silly me! Thanks!!
Is there a way to order it in the order you’ve set in the product gallery?
Also there seems to be loading issues if you use the ‘display posts’ shortcode. The carousel shows the first image but leaves a grey space underneath (size depends on how many images in carousel)… Once you refresh it works normally though.
@bounty_digital I tweaked the snippet a little. Using post__in for the orderby param, the carousel will respect the order of the images in the product gallery:
add_filter( 'the_content', 'wpbc_woo_the_content', 10, 1 );
function wpbc_woo_the_content( $content )
{
if( ! is_singular( 'product' ) )
return $content;
global $product;
if( $product->get_gallery_attachment_ids() )
{
$content = $content . do_shortcode( '[display-posts orderby="post__in" post_type="attachment" id="' . get_post_meta( $product->post->ID, '_product_image_gallery', true ) . '" bootstrap="1" unwrap="1"]' );
}
return $content;
}
About the grey space, sounds like a rather specific issue, but I might be wrong. Are you using a Bootstrap powered theme?