WordPress.org

Forums

WooCommerce - excelling eCommerce
Changing images for different variations (1 post)

  1. antoniomvprg
    Member
    Posted 1 year ago #

    Hi

    My theme displays only the featured image, and the images from the gallery, but i want it to fetch the images from each variation, and that they change when one changes the variation.

    I got this code from functions/fetch-product.php:

    <ul class="gallery-container gallery-image clearfix">
    
    <?php $attach_args = array("post_type" => "attachment", "post_parent" => $post->ID, "numberposts" => "-1", "orderby" => "menu_order", "order" => "ASC");
    
    $attachments = get_posts($attach_args);
    
    if ( !empty($attachments) ) :
    
    foreach($attachments as $attachement => $this_attachment) :  
    
    $image = wp_get_attachment_image_src($this_attachment->ID, "340");
    
    $full = wp_get_attachment_image_src($this_attachment->ID,  "full"); ?>
    
    <li>
    
    <a href="<?php echo $full[0]; ?>" rel="lightbox">
    
    <img src="<?php echo $image[0]; ?>" alt="<?php echo $this_attachment->post_title; ?>" />
    
    </a>
    
    </li>

    Can someone help me?

    António

    https://wordpress.org/plugins/woocommerce/

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • WooCommerce - excelling eCommerce
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic