A small NEW label on recently added products helps returning customers spot what has changed since their last visit. WooCommerce has no setting for it, but a short snippet adds one: it marks every product created in the last 30 days, and you can change that to any period or a fixed start date. There is one version for classic themes and one for block themes.

Step 1: decide which products are new
Add this to your child theme's functions.php or to a code snippets plugin such as Code Snippets. You need it whichever theme you use.
/**
* True when a product was created after the cut-off below.
*/
function wf_is_new_product( $product ): bool {
if ( ! $product instanceof WC_Product ) {
return false;
}
$created = $product->get_date_created(); // WC_DateTime, or null if no date is set.
if ( ! $created ) {
return false;
}
// Products created after this point count as new.
// Use a relative time ('30 days ago', 'last Monday') or a date ('1 November 2026').
$since = date_create_immutable( '30 days ago', wp_timezone() );
return $since && $created->getTimestamp() >= $since->getTimestamp();
}
/**
* The badge markup.
*/
function wf_new_badge_html(): string {
return '<span class="wf-new-badge">' . esc_html__( 'New', 'wf' ) . '</span>';
}get_date_created() returns a WC_DateTime object, or null when a product has no date, so the function checks for that before it compares timestamps.
Step 2: show the badge
Add one of the next two snippets, not both. For compatibility, WooCommerce can still fire both classic hooks used below on block-theme shop and product pages, so adding both snippets can print the badge twice.
Classic themes
Classic themes such as Storefront build shop and product pages from WooCommerce's PHP templates. This puts the badge above the product image in shop, category and related product grids, and above the title on the product page.
// Shop, category and related product grids: above the product image.
add_action( 'woocommerce_before_shop_loop_item', 'wf_show_new_badge', 5 );
// Single product page: above the product title.
add_action( 'woocommerce_single_product_summary', 'wf_show_new_badge', 4 );
function wf_show_new_badge() {
global $product;
if ( wf_is_new_product( $product ) ) {
echo wf_new_badge_html(); // Escaped in wf_new_badge_html().
}
}woocommerce_before_shop_loop_item only runs inside product grids, which is why the product page needs its own hook, woocommerce_single_product_summary. Priority 4 places the badge just before the title, which WooCommerce adds at priority 5.
Block themes
Block themes such as Twenty Twenty-Five use WooCommerce's block templates, where most of those PHP hooks don't run. Filter the Title block instead: WooCommerce's shop, category and product templates, its related products section and Product Collection blocks all use it for the product name.
// Every Title block that shows a product: shop grids, related products and the product page.
add_filter( 'render_block_core/post-title', 'wf_new_badge_before_title', 20, 3 );
function wf_new_badge_before_title( $block_content, $block, $instance ) {
$post_id = $instance instanceof WP_Block ? (int) ( $instance->context['postId'] ?? 0 ) : 0;
if ( ! $post_id || 'product' !== get_post_type( $post_id ) ) {
return $block_content;
}
if ( ! wf_is_new_product( wc_get_product( $post_id ) ) ) {
return $block_content;
}
return wf_new_badge_html() . $block_content;
}The filter runs for every Title block on the site, so it checks that the post is a product before doing anything else. The badge sits just above the product name. If your product templates still use the Classic Template block, WooCommerce renders its PHP templates there, so use the classic version instead.
Step 3: style it
The badge has its own class, wf-new-badge. Reusing WooCommerce's onsale class would give it the sale badge's position, so the two would sit on top of each other on a new product that is also on sale. Add this CSS in Appearance > Customize > Additional CSS (classic themes) or in Appearance > Editor > Styles, then More > Additional CSS (block themes):
.wf-new-badge {
display: inline-block;
margin-bottom: 0.5em;
padding: 0.2em 0.6em;
border: 1px solid currentColor;
border-radius: 3px;
font-size: 0.75rem;
font-weight: 600;
line-height: 1.4;
letter-spacing: 0.05em;
text-transform: uppercase;
}The border takes the text colour, so the badge suits light and dark themes without changes.
Change what counts as new
The cut-off is the '30 days ago' string in wf_is_new_product(). Replace it with:
- another period, such as
'14 days ago'or'2 weeks ago' - a fixed date, such as
'1 November 2026', to mark everything added since a launch - a relative day, such as
'last Monday'
PHP reads the string with date_create_immutable() in your site's time zone, and the supported date and time formats page lists what it accepts. If PHP can't read the string, no product gets the badge and the site carries on working.
To show how much a sale saves as well, see how to display the discount percentage. For badges driven by stock, tags or custom fields, talk to our WooCommerce developers.