
<div class="banner-sale">
    <img src="/wp-content/uploads/2022/05/banner.jpg" alt="">
</div>

<div class="sidebar-product">
    <div class="product-box">
        <h3 class="sale-title"><?php _e( 'Sản phẩm bán chạy', 'tbang_text' ) ?></h3>
        
        <?php 
        $args = array(
            'post_type'              => array( 'product' ),
            'posts_per_page'         => '2',
        );

        $query = new WP_Query( $args );
        if ( $query->have_posts() ) {
            echo '<div class="best-seller">';
            while ( $query->have_posts() ) { $query->the_post(); ?>
            
                <div class="product-item">
                    <div class="wrap-img">
                        <a href="<?php the_permalink() ?>">
                            <img src="<?php echo custom_image_size( get_the_ID(), 390, 440, true ) ?>" alt="<?php the_title_attribute( ) ?>">
                        </a>
                    </div>
                    <div class="wrap-info">
                        <h3 class="title"><a href="<?php the_permalink() ?>"><?php the_title() ?></a></h3>

                        <?php product_price( get_field( 'price' ), get_field( 'sale_price' ), 'related' ) ?>
                        <a href="<?php the_permalink() ?>" class="btn-buy"><?php _e( 'Mua ngay', 'tbang_text' ) ?></a>
                    </div>
                </div>
        <?php 
            }
            echo '</div>';
        }

        wp_reset_postdata();
        ?>                                            
    </div>
</div>