Code slider brand cho plugin Perfect Brands for WooCommerce dùng trên theme Flatsome

4.5/5 – (145 bình chọn)

Hôm nay mình xin chia sẻ đoạn code slider brand, áp dụng cho plugin Perfect Brands for WooCommerce và dùng trên theme flatsome, theme khác thì xài không được nhé, muốn xài thì phải sửa code lại nhé.

Giờ thì copy đoạn code, bỏ vô functions.php của flatsome child đang dùng nhé.

function pmo_brands_slider()
{
    $ux_slider = '[ux_slider arrows="false" freescroll="false" bullets="false"]';
    
    $display   = false;
    $terms     = get_terms([
        'taxonomy'   => 'pwb-brand',
        'hide_empty' => false,
    ]);

    if ($terms) {
        foreach ($terms as $term) {
            $image = get_term_meta($term->term_id, 'pwb_brand_image', true);

            if ($image) {
                $display    = true;
                $ux_slider .= '[logo hover="color" img="' . $image . '" link="' . get_term_link($term) . '" image_size="original" height="50px"]';
            }
        }
    }

    $ux_slider .= '[/ux_slider]';

    if ($display) {
        echo do_shortcode($ux_slider);
    }
}
add_shortcode('brands_slider', 'pmo_brands_slider');

 

Comments

No comments yet. Why don’t you start the discussion?

Leave a Reply

Your email address will not be published. Required fields are marked *