Display featured products - WooCommerce

Published on Apr 23, 2016 & tagged in WordPress, WooCommerce

In WooCommerce, there is option to make a product as featured one. That means, we can simply highlight / list out our special products.

To display featured products, we have two options.

Using Short Code

[featured_products per_page="8" columns="4" orderby="date" order="desc"]

Using WordPress Query

$args = array(  
	'post_type' => 'product',  
	'meta_key' => '_featured',  
	'meta_value' => 'yes',  
	'posts_per_page' => 4  
);  
  
$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
		var_dump($product);
		  
	endwhile;  
	  
endif;  
  
wp_reset_query(); // Reset Our Query

Do you need any help on WordPress & WooCommerce?

I'm happy to help you. Just fill the form on contact page & I will get back to you within few hours.

Recent Posts

  1. The add_image_size() function - WordPress best practices
  2. Remove page title using filter - WordPress
  3. Comment out code in Liquid Template Language
  4. Remove Plugin Stylesheets and Scripts - WordPress
  5. Get blog page URL - WordPress