function pro_grid_loop(){ //ob_start(); //wp_reset_postdata(); ?> <?php $arg = array( 'post_type' => 'product', 'posts_per_page' =>6, 'product_cat' => 'best-seller' ); $pro = new WP_Query($arg); ?> <div class="row grid_prod"> <?php if ($pro->have_posts() ): ?> <?php while ($pro->have_posts() ) : ?> <?php $pro->the_post(); global $product; $eid = get_the_ID(); ?> <div class="col-md-4"> <img width="300" height="300" src="<?php echo get_the_post_thumbnail_url($product_id);?>"/> <h2 class="singleProd_title"><?php echo $product->get_title(); ?></h2> <span class="woocommerce-Price-currencySymbol">$</span><?php echo $product->get_price(); ?></bdi></span> </div> <?php endwhile; ?> <?php endif;?> </div> <?php wp_reset_postdata(); //return ''.ob_get_clean(); } add_shortcode('best_product_grid', 'pro_grid_loop');