Lượt xem | |
Hiện tại: | |
1h trước: | |
24h trước: | |
Tổng số: |
Mời anh chị xem video Hướng dẫn custom woocommerce phần 11
Nội dung video: hướng dẫn custom feature image product (ảnh đại diện sản phẩm ) và gallery product (ảnh sản phẩm: nhiều hình ảnh về sản phẩm)
Trước khi anh chi vào bài viết này nên xem qua bài viết Các khái niệm featured image, thumbnail, add image size là gì?
Một số code liên quan đến video:
remove_action("woocommerce_before_single_product_summary","woocommerce_show_product_images",20);
function custom_get_featured_image(){ global $post; echo get_the_post_thumbnail(get_the_ID(), 'shop_single' ); } add_action("woocommerce_before_single_product_summary","custom_get_featured_image",20);
add_filter( 'woocommerce_product_tabs', 'add_new_product_tab' ); function add_new_product_tab( $tabs ) { // Adds the new tab $tabs['hinh_anh_san_pham'] = array( 'title' => __( 'Hình ảnh sản phẩm', 'woocommerce' ), 'priority' => 50, 'callback' => 'tab_hinh_san_pham' ); return $tabs; } function tab_hinh_san_pham(){ global $post; $_product_image_gallery = get_post_meta($post->ID,"_product_image_gallery",true); $_product_image_gallerys = explode("," ,$_product_image_gallery); if($_product_image_gallerys): foreach($_product_image_gallerys as $id_image): //$post_thumbnail_id = get_post_thumbnail_id($id_image); $src_thumbnail =wp_get_attachment_image_src($id_image ,'full'); ?>
![]()
2016-03-16 20:26:05
Nguồn: http://fcwordpress.net/huong-dan-custom-woocommerce-phan-11.html