I wrote my own shortcode for woocommerce.
The code works fine on content-single-product.php. Any other page though, and my site breaks. Why?
Fatal error: Call to a member function get_gallery_image_ids() on null in /mysite/wp-content/plugins/woocommerce/templates/single-product/product-thumbnails.php on line 27
This is the function i wrote:
/* My custom shortcode code*/
function get_woocommerce_gallery_image_thumbnails ( $atts ) {
// Buffer our contents
ob_start();
/* Line to get the gallery thumbnails */
wc_get_template( 'single-product/product-thumbnails.php');
// Return buffered contents
return ob_get_clean();
}
add_shortcode( 'wc_get_thumbs', 'get_woocommerce_gallery_image_thumbnails' );