Sunday, June 12, 2022
HomeWordPress Developmentload extra button duplicates earlier merchandise

load extra button duplicates earlier merchandise


Right here is my handler to ajax request. What’s my downside?

operate loadmore_ajax_handler(){
        $args = [];
        $args['paged'] = $_POST['page'];
        $args['posts_per_page'] = 3;
        $args['post_type'] = 'product';
        query_posts($args);
        $response = [];

        whereas( have_posts() ): the_post();
            $product = wc_get_product(get_the_ID());

            $response[] = '
                <div class="catalog-goods-wrapper--card">
                    <img src="' . get_the_post_thumbnail_url() .'" alt="footwear" class="catalog-goods--good-preview" />
                    <div class="catalog-goods-wrapper--overlay"></div> 
                </div>
                <p class="catalog-goods--description">' . get_the_title() . '</p>
                <span class="catalog-goods--price">' . $product->get_price_html() . '</span>
                <i class="view-good"></i>';
                
            

        endwhile;
        wp_reset_query();

        echo json_encode($response);
        
        die; 
    }
RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisment -
Google search engine

Most Popular

Recent Comments