Bạn đang xây dựng một website bằng theme Flatsome và muốn hiển thị các đánh giá khách hàng chuyên nghiệp, đẹp mắt, tùy chỉnh linh hoạt? Trong bài viết này, mình sẽ chia sẻ thủ thuật Flatsome giúp bạn tạo shortcode đánh giá khách hàng có hình ảnh, sao đánh giá, hiệu ứng đẹp mắt, đặc biệt là tích hợp trực tiếp trong UX Builder để dễ dàng kéo thả!

Lợi ích của việc hiển thị đánh giá khách hàng bằng shortcode tùy biến
Tăng độ tin tưởng từ khách truy cập.
Nâng cao trải nghiệm người dùng với giao diện đẹp, tương tác mượt mà.
Tùy chỉnh linh hoạt: màu sắc, số sao, vị trí ảnh, hiệu ứng hover.
Tối ưu SEO với từ khóa liên quan đến sản phẩm/dịch vụ.
Tạo Shortcode Đánh Giá Khách Hàng
Chèn đoạn mã sau vào cuối file functions.php trong theme con của bạn:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 | // Shortcode đánh giá khách hàng - muathemewpgiare.com function muathemewpgiare_review_shortcode($atts) { $atts = shortcode_atts(array( 'title' => 'Khách hàng nói gì?', 'stars' => 5, 'content' => 'Sản phẩm rất tuyệt vời, giao hàng đúng hẹn.', 'title_color' => '#333333', 'text_color' => '#666666', 'bg_color' => '#f9f9f9', 'image_id' => '', 'star_icon' => '★', 'star_empty_icon' => '☆', 'hover_effect' => 'true', 'image_position' => 'below', 'padding' => '20px', 'margin' => '10px', 'image_size' => '60px', 'border_radius' => '50%', ), $atts, 'muathemewpgiare_review'); $stars_html = ''; for ($i = 1; $i <= 5; $i++) { $stars_html .= '<span class="star">' . ($i <= intval($atts['stars']) ? esc_html($atts['star_icon']) : esc_html($atts['star_empty_icon'])) . '</span>'; } $image_url = $atts['image_id'] ? wp_get_attachment_image_url($atts['image_id'], 'thumbnail') : ''; ob_start(); ?> <div class="muathemewpgiare-review <?= esc_attr($atts['image_position']); ?>" style="background: <?= esc_attr($atts['bg_color']); ?>; padding: <?= esc_attr($atts['padding']); ?>; margin: <?= esc_attr($atts['margin']); ?>; border-radius: 12px; display: flex; flex-direction: <?= in_array($atts['image_position'], ['above', 'below']) ? 'column' : 'row'; ?>; align-items: center; gap: 20px;"> <?php if (in_array($atts['image_position'], ['above', 'left']) && $image_url): ?> <div class="reviewer-image"> <img src="<?= esc_url($image_url); ?>" style="width: <?= esc_attr($atts['image_size']); ?>; height: <?= esc_attr($atts['image_size']); ?>; border-radius: <?= esc_attr($atts['border_radius']); ?>; object-fit: cover;"> </div> <?php endif; ?> <div class="review-content" style="flex: 1; text-align: center;"> <h3 style="color: <?= esc_attr($atts['title_color']); ?>;"><?= esc_html($atts['title']); ?></h3> <div class="stars" style="color: #f5a623; font-size: 20px;"><?= $stars_html; ?></div> <p style="color: <?= esc_attr($atts['text_color']); ?>;"><?= esc_html($atts['content']); ?></p> </div> <?php if (in_array($atts['image_position'], ['right', 'below']) && $image_url): ?> <div class="reviewer-image"> <img src="<?= esc_url($image_url); ?>" style="width: <?= esc_attr($atts['image_size']); ?>; height: <?= esc_attr($atts['image_size']); ?>; border-radius: <?= esc_attr($atts['border_radius']); ?>; object-fit: cover;"> </div> <?php endif; ?> </div> <?php if ($atts['hover_effect'] === 'true'): ?> <style> .muathemewpgiare-review .star { transition: transform 0.3s ease; } .muathemewpgiare-review:hover .star { transform: scale(1.2); } </style> <?php endif; return ob_get_clean(); } add_shortcode('muathemewpgiare_review', 'muathemewpgiare_review_shortcode'); |
Tích Hợp Shortcode Vào UX Builder của Flatsome

Để có thể sử dụng shortcode này trực tiếp trong UX Builder, bạn tiếp tục chèn đoạn code sau vào functions.php:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 | function muathemewpgiare_register_element_to_uxbuilder() { add_ux_builder_shortcode('muathemewpgiare_review', array( 'name' => __('Đánh giá - muathemewpgiare'), 'category' => __('Content'), 'priority' => 10, 'options' => array( 'title' => array( 'type' => 'textfield', 'heading' => 'Tiêu đề', 'default' => 'Khách hàng nói gì?' ), 'stars' => array( 'type' => 'slider', 'heading' => 'Số sao (1-5)', 'min' => 1, 'max' => 5, 'default' => 5 ), 'content' => array( 'type' => 'textarea', 'heading' => 'Nội dung đánh giá', 'default' => 'Sản phẩm rất tuyệt vời, giao hàng đúng hẹn.' ), 'image_id' => array( 'type' => 'image', 'heading' => 'Ảnh người đánh giá' ), 'image_position' => array( 'type' => 'select', 'heading' => 'Vị trí ảnh', 'options' => array( 'above' => 'Trên nội dung', 'below' => 'Dưới nội dung', 'left' => 'Bên trái', 'right' => 'Bên phải', ), 'default' => 'below' ), 'image_size' => array( 'type' => 'textfield', 'heading' => 'Kích thước ảnh', 'default' => '60px' ), 'border_radius' => array( 'type' => 'textfield', 'heading' => 'Bo góc ảnh', 'default' => '50%' ), 'star_icon' => array( 'type' => 'textfield', 'heading' => 'Sao đầy', 'default' => '★' ), 'star_empty_icon' => array( 'type' => 'textfield', 'heading' => 'Sao rỗng', 'default' => '☆' ), 'hover_effect' => array( 'type' => 'checkbox', 'heading' => 'Hiệu ứng khi hover', 'default' => true ), 'title_color' => array( 'type' => 'colorpicker', 'heading' => 'Màu tiêu đề', 'default' => '#333333' ), 'text_color' => array( 'type' => 'colorpicker', 'heading' => 'Màu nội dung', 'default' => '#666666' ), 'bg_color' => array( 'type' => 'colorpicker', 'heading' => 'Màu nền', 'default' => '#f9f9f9' ), 'padding' => array( 'type' => 'textfield', 'heading' => 'Padding', 'default' => '20px' ), 'margin' => array( 'type' => 'textfield', 'heading' => 'Margin', 'default' => '10px' ), ), )); } add_action('ux_builder_setup', 'muathemewpgiare_register_element_to_uxbuilder'); |
Cách sử dụng trong bài viết hoặc UX Builder
Dùng trực tiếp shortcode trong nội dung:
1 | [muathemewpgiare_review title="Khách hàng ABC" stars="4" content="Dịch vụ tuyệt vời!" image_id="123"] |
- Hoặc mở UX Builder → Thêm Đánh giá – muathemewpgiare và tùy chỉnh giao diện trực tiếp.
Tổng Kết
Đây là thủ thuật Flatsome cực hay giúp bạn hiển thị đánh giá khách hàng đẹp, dễ tùy chỉnh và tích hợp UX Builder. Nếu bạn đang phát triển website bán hàng, dịch vụ, hay portfolio – thì đây là tính năng không thể thiếu để tăng uy tín và chuyển đổi khách hàng.
- Bảo Mật Trang Web WordPress – Hướng Dẫn Toàn Diện Giúp Website An Toàn Tuyệt Đối
- 5 Sai Lầm Khi Sử Dụng Plugin Nulled và Cách Tránh Mất Dữ Liệu
- Sharecode flatsome mỹ phẩm giống thẩm mỹ viện Mailisa giống đến 99%
- Claude qua GitHub Copilot: so sánh Claude Code và GitHub Copilot trong lập trình
- Tối Ưu Hóa Đường Dẫn URL Cho Website Năm 2025

