skip to Main Content

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?

2

Answers


  1. Chosen as BEST ANSWER

    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' );
    

  2. Testing with a default theme of Twenty Twenty and using that same shortcode (all plugins and theme up to date) it works fine. This generally stems from a custom theme or plugin conflict(s).

    Try changing to a default theme to test if it works there not within the one you are using.

    Regarding plugins, disable everything not needed and try then start enabling them one at a time.

    As well, posting a link to a dev or staging version of the site in question could also help.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search