WooCommerce: Add Custom Badge To Featured Products @ Shop Page

If you’ve ever wanted to customize how WooCommerce featured products appear on your classic product grid (Shop, Category, Tag, archive, search, shortcode pages) or Product Collection block, you’re in the right place!

For example, adding a custom label gives your featured products the attention they deserve and helps them stand out, catching the eye of your shoppers. Amazon does that, for example.

Whether you want to create a sleek, minimalist tag or a bold, colorful banner, a bit of custom code can transform your product display and enhance your store’s design.

In this guide, you’ll discover how to add a fully customizable label specifically for featured products in WooCommerce. With a simple CSS code snippet, you can take control of your shop’s visual identity. Read on to find the solution and start enhancing your store today!

The Yoga block and Yoga bag are featured products. The frontend now shows these custom badges!

CSS Snippet: Display “Staff Pick” Label On Featured Products @ Classic Shop or Product Collection Block

One thing you didn’t know, maybe, is that WooCommerce adds the “featured” CSS class to each list item that has been manually starred in the WordPress Dashboard. All we need is targeting that class in our custom CSS!

Note: this is CSS, not PHP. You should place this in your child theme’s style.css or under WP Dashboard > Appearance > Customize > Additional CSS.

/**
 * @snippet       Custom CSS Badge For WooCommerce Featured Products
 * @tutorial      Get CustomizeWoo.com FREE
 * @author        Rodolfo Melogli, Business Bloomer
 * @compatible    WooCommerce 9
 * @community     https://businessbloomer.com/club/
 */

li.featured { 
   position: relative 
}

li.featured:before { 
   padding: 3px 8px; 
   text-align: center; 
   background: #222; 
   color: white; 
   font-weight: bold; 
   position: absolute; 
   top: 6px; 
   right: 6px; 
   font-size: 12px; 
   content: "Staff Pick"; 
   z-index: 10 
}

Here’s the explanation for the CSS:

  1. li.featured:
    • This targets any <li> element with the class featured.
    • The position: relative; ensures that the pseudo-element :before is positioned relative to this <li> rather than the entire document.
  2. li.featured:before:
    • This adds a pseudo-element before the content of the <li> with the class featured.
    • padding: 3px 8px;: Adds space inside the label for proper spacing around the text.
    • text-align: center;: Centers the text inside the label horizontally.
    • background: #222;: Sets a dark gray background color for the label.
    • color: white;: Sets the label text color to white for contrast against the background.
    • font-weight: bold;: Makes the text bold to stand out.
    • position: absolute;: Positions the label relative to the parent <li> element.
    • top: 6px; and right: 6px;: Places the label in the top-right corner of the <li> element, offset by 6px.
    • font-size: 12px;: Specifies the size of the text inside the label.
    • content: "Staff Pick";: The text displayed in the label. You can replace "Staff Pick" with any custom text.
    • z-index: 10;: Ensures the label appears on top of other overlapping elements.

This CSS creates a visually distinct badge for featured list items, perfect for highlighting special products or recommendations.

Where to add custom code?

You should place custom PHP in functions.php and custom CSS in style.css of your child theme: where to place WooCommerce customization?

This code still works, unless you report otherwise. To exclude conflicts, temporarily switch to the Storefront theme, disable all plugins except WooCommerce, and test the snippet again: WooCommerce troubleshooting 101

Related content

Rodolfo Melogli

Business Bloomer Founder

Author, WooCommerce expert and WordCamp speaker, Rodolfo has worked as an independent WooCommerce freelancer since 2011. His goal is to help entrepreneurs and developers overcome their WooCommerce nightmares. Rodolfo loves travelling, chasing tennis & soccer balls and, of course, wood fired oven pizza. Follow @rmelogli

4 thoughts on “WooCommerce: Add Custom Badge To Featured Products @ Shop Page

  1. Do you think the theme to replace storefront for blocks theme will be good? I am not confident about it but Storefront really needs a rebuild.

    1. I run Business Bloomer on Storefront, and many still use it. If you’re into blocks, then, yes, whatever they release will be better than the current one lol!

  2. This should be included in WooCommerce !

Questions? Feedback? Customization? Leave your comment now!
_____

If you are writing code, please wrap it like so: [php]code_here[/php]. Failure to complying with this, as well as going off topic or not using the English language will result in comment disapproval. You should expect a reply in about 2 weeks - this is a popular blog but I need to get paid work done first. Please consider joining the Business Bloomer Club to get quick WooCommerce support. Thank you!

Your email address will not be published. Required fields are marked *