Notice: These forums are now retired and closed. For active support, please Submit a Ticket or visit our official WordPress.org community pages.
Kadence Theme | Kadence Blocks | Starter Templates | WooCommerce Email Designer | Ascend | Virtue | Pinnacle

badge “new” in single product template

Home / Forums / Kadence Theme / badge “new” in single product template

This topic is: Awaiting Feedback
[Awaiting Feedback]
Posted in: Kadence Theme
February 26, 2024 at 11:44 am

Hello,

I had this badge created with code found on the web but since I use a sigle product template in Kadence it doesn’t work anymore.

I guess I’m missing the position to display the badge in the template…

Is there a way to add it?

add_action( 'woocommerce_before_shop_loop_item_title', 'bbloomer_new_badge_shop_page', 3 );

function bbloomer_new_badge_shop_page() {
global $product;
$newness_days = 15;
$created = strtotime( $product->get_date_created() );
if ( ( time() - ( 60 * 60 * 24 * $newness_days ) ) < $created ) {
echo '' . esc_html__( 'New!', 'woocommerce' ) . '';
}
}

  • The forum ‘Kadence Theme’ is closed to new topics and replies.