This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*** Add to Child Theme functions.php to show media caption under product thumbnails in the WooCommerce Product Gallery. ***/ | |
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; |