How to get woocommerce featured products in wordpress inside a product loop. We provide below code to get woocommerce featured products in loop. Woocommerce by default provide the short code to view featured products.
We can display WooCommerce Featured Products Without a Shortcode.
What is Featured Products in WordPress?
When logged into WordPress simply navigate to the ‘Products’ section and you’ll notice that there is a column containing stars. See in screenshot..
If a star in this column is black it means it is featured. To add or remove a product to the list of featured products you simply click the star. Copy and paste below code in your template file.
$args = array( 'post_type' => 'product', 'meta_key' => '_featured', 'meta_value' => 'yes', 'posts_per_page' => 1 );$featured_query = new WP_Query( $args );if ($featured_query->have_posts()) : while ($featured_query->have_posts()) : $featured_query->the_post(); $product = get_product( $featured_query->post->ID ); // Output product information here endwhile; endif; wp_reset_query();