questions

Load flexslider on different page in Woocommerce

Rate this post

I have loaded a product on my home page using this shortcode

<?php echo do_shortcode('[product_page id="195"]');?>

Which loads the product with main image and small thumbnails below it and on right side product title, price, quantity and add to cart button. Which is what I needed. But the images does not have the sliding feature or zoom feature working. As per my knowledge, if you check on specific product page, it loads flex slider and jquery zoom plugin on the product images so they can slide as a carousel and clicking on them zooms the image.

Any idea how I can make this feature work on my Home page aswell?

 

✔️Solution:

I managed to fix this using following code.

// Enqueue/Add CSS and JS files
function amd_enqueue(){
  // here home-page.php is the name of the template where it needs to load
  if(is_page_template("home-page.php")){
      wp_enqueue_script('zoom');
      wp_enqueue_script('flexslider');
      wp_enqueue_script('photoswipe-ui-default');
      wp_enqueue_style('photoswipe-default-skin');
      add_action( 'wp_footer', 'woocommerce_photoswipe' );
  }
}

add_action( 'wp_enqueue_scripts', 'amd_enqueue' );

Leave a Reply

Your email address will not be published.

Back to top button