Đoạn này để show gallery ra trang shop
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
//* Add gallery thumbs to woocommerce shop page add_action('woocommerce_shop_loop_item_title','wps_add_extra_product_thumbs',5); function wps_add_extra_product_thumbs() { if ( is_shop() ) { global $product; $attachment_ids = $product->get_gallery_attachment_ids(); echo '<div class="product-thumbs">'; foreach( array_slice( $attachment_ids,0,3 ) as $attachment_id ) { $thumbnail_url = wp_get_attachment_image_src( $attachment_id,'thumbnail' )[0]; echo '<img class="thumb" src="' . $thumbnail_url . '">'; } echo '</div>'; } } |
Bài viết mới: