Hướng Dẫn show Attributes trang chi tiết sản phầm

Bước 1. Chép toàn bộ code dưới vào function.php AE thay thế các biến thành tên thuộc tính của trang mình cho phù hợp nhé. Ko rõ thì ae comment.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354 // SHOW INFO GACHadd_action( ‘woocommerce_single_product_summary’, ‘show_additional_info_gach_product_summary’, 5);// To diplay additonal info via shortcode within product pageadd_shortcode( ‘show_info_gach’, ‘show_additional_info_gach_product_summary’ );function show_additional_info_gach_product_summary() {global $product;$brand_attributes = $product->get_attribute(‘thuong-hieu’);$xuatxu_attributes = $product->get_attribute(‘xuat-xu’);$kichthuoc_attributes = $product->get_attribute(‘kich-thuoc’);$bemat_attributes = $product->get_attribute(‘be-mat’);$chungloai_attributes = $product->get_attribute(‘chung-loai’);$hoatiet_attributes = $product->get_attribute(‘hoa-tiet’);$mausac_attributes = $product->get_attribute(‘mau-sac’);$donvitinh_attributes = $product->get_attribute(‘don-vi-tinh’);?><p class=”info-gach”><ul class=”ul-info-gach”><li>Mã: <?php echo $product->get_sku(); ?></li><?php if (!empty($brand_attributes)) : ?><li>Thương hiệu: <?php echo $brand_attributes; ?></li><?php endif; ?><?php if (!empty($xuatxu_attributes)) : ?><li>Xuất xứ: <?php echo $xuatxu_attributes; ?></li><?php endif; ?><?php if (!empty($kichthuoc_attributes)) : ?><li>Kích thước: <?php echo $kichthuoc_attributes; ?></li><?php endif; ?><?php if (!empty($bemat_attributes)) : ?><li>Bề mặt: <?php echo $bemat_attributes; ?></li><?php endif; ?><?php if (!empty($chungloai_attributes)) : ?><li>Chủng loại: <?php echo $chungloai_attributes; ?></li><?php endif; ?><?php if (!empty($mausac_attributes)) : ?><li>Màu sắc: <?php echo $mausac_attributes; ?></li><?php endif; ?><?php if (!empty($donvitinh_attributes)) : ?><li>Đơn vị tính: <?php echo $donvitinh_attributes; ?></li><?php endif; ?></ul></p><?php}
Bước 2
Dán short code vào khu vực muốn hiện (flatsome).
= > trong text dán
[show_info_gach]
trong Php dán
<?php echo do_shortcode(‘[show_info_gach]’); ?>
Nguồn : Bùi Thế Hùng – Group NGHIỆN WORDPRESS ✅ VietCoders Community
Từ code send của bác @Hùng ta có cái cần xem 🙂

Với doạn code ta tạo short bất kỳ qua file function.php
add_shortcode( ‘show_info_gach‘, ‘show_additional_info_gach_product_summary’ );
function show_additional_info_gach_product_summary() {
?>
thêm nội dung bất kỳ ở đây ( có thể thêm code HTM hoặc PHP )
<?php
}
2. Đổi tên show_info_gach = > thành tên bất kỳ mà bạn muốn
3 . Chèn short bất cứ đâu mà bạn thích
– Dạng text
[show_info_gach]
trực tiếp PHP
<?php echo do_shortcode(‘[show_info_gach]’); ?>