Show Featured WooCommerce Products

Quick Summary

  • A WP_Query with a tax_query for the featured term of product_visibility lists featured WooCommerce products anywhere in a template.
  • wc_get_template_part() loads content-product.php so products match your shop page; wrap the loop in a ul element with the products class.
  • Inside page content, the products shortcode with visibility set to featured shows featured products without any PHP.

This snippet lists featured WooCommerce products anywhere in a theme template, for example in a section of a custom home page. Featured products are the ones marked with the star in Products > All Products.

Place the code in the template file of your child theme where the products should appear.

PHP
    $args = array(
        'post_type' => 'product',
        'posts_per_page' => 12,
        'tax_query' => array(
                array(
                    'taxonomy' => 'product_visibility',
                    'field'    => 'name',
                    'terms'    => 'featured',
                ),
            ),
        );
    $loop = new WP_Query( $args );
    if ( $loop->have_posts() ) {
        while ( $loop->have_posts() ) : $loop->the_post();
            wc_get_template_part( 'content', 'product' );
        endwhile;
    } else {
        echo __( 'No products found' );
    }
    wp_reset_postdata();

How it works

  • WooCommerce stores the featured flag as the featured term of its internal product_visibility taxonomy, so the tax_query asks WP_Query for products that have that term.
  • posts_per_page sets how many products are shown. Change 12 to the number you need.
  • wc_get_template_part( 'content', 'product' ) loads WooCommerce’s content-product.php template, so each product looks the same as on your shop page.
  • If no product is featured, the else branch prints No products found.
  • wp_reset_postdata() restores the main query’s post afterwards, so the rest of the template keeps working as expected.

Tips

  • content-product.php outputs each product as an <li>, so wrap the loop in <ul class="products"> to get valid markup that matches the structure of the shop page.
  • If you only need featured products inside a page’s content, WooCommerce’s [products visibility="featured"] shortcode shows them without any PHP.
Share on X (opens in a new tab) Share on LinkedIn (opens in a new tab) Share on Facebook (opens in a new tab)

ChatGPT (opens in a new tab) Claude (opens in a new tab) Gemini (opens in a new tab) Perplexity (opens in a new tab) Grok (opens in a new tab)

More Insights

See More