• Resolved sabineblume

    (@sabineblume)


    I am looking to add a caption under the product gallery image thumbnail(s). I found this code, which works, but it displays the caption under the large main image:

    add_filter('woocommerce_single_product_image_thumbnail_html', function($html, $attachment_id) {
      $caption = get_post_field('post_excerpt', $attachment_id);
    
      if(trim($caption)) {
        $html = str_replace('</div>', '<span class="gtnCaps">' . $caption . '</span></div>', $html);
      }
    
      return $html;
    }, 10, 2);

    How can I tweak this code so the caption displays under the small thumbnail image(s) of the product gallery instead?

Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Caption under product gallery thumbnails’ is closed to new replies.