WooCommerce Image Gallery Shortcode

WooCommerce does not provide a woocommerce image gallery shortcode to be used in Beaver Builder Themer or other page builders. But sometimes you want to develop a different WooCommerce template that places the featured image gallery in a different location than the default.

You can add the following code to your child theme’s functions.php file. Then use the shortcode [woo-gallery] in your page builder’s HTML module and place it anywhere you like.


add_shortcode('woo-gallery', 'woo_gallery_func');
function woo_gallery_func($atts, $content){
ob_start();
$path = WooCommerce::plugin_path();
include($path . '/templates/single-product/product-thumbnails.php');
$output = ob_get_contents();
ob_end_clean();
return $output;
}

Let me know how that works or if you need a hand getting that done.

Menu Title