{"id":2478,"date":"2017-10-24T01:45:19","date_gmt":"2017-10-24T01:45:19","guid":{"rendered":"http:\/\/docs.contentviewspro.com\/?p=2478"},"modified":"2023-12-27T09:04:01","modified_gmt":"2023-12-27T09:04:01","password":"","slug":"woocommerce-new-product-badge","status":"publish","type":"docs","link":"https:\/\/contentviewspro.com\/documentation\/article\/woocommerce-new-product-badge\/","title":{"rendered":"WooCommerce &#8211; show the &#8220;NEW&#8221; badge for latest products"},"content":{"rendered":"<p>Content Views Pro helps you to select and show WooCommerce products easily without coding.<br \/>\nTo display the NEW badge for WooCommerce products, Please add this code to file <strong>functions.php<\/strong> in the directory of your active theme:<\/p>\n<pre style=\"font-size:13px\">\n\/\/ Content Views Pro - Display New badge for WooCommerce products\nadd_filter( 'pt_cv_field_thumbnail_image_html', 'cvp_theme_woocommerce_new_badge', 100 );\nfunction cvp_theme_woocommerce_new_badge( $args ) {\n\tif ( PT_CV_Functions::get_global_variable( 'content_type' ) === 'product' ) {\n\t\tglobal $post;\n\t\t$hours\t = 72; \/* TODO: change this value to number of hours to calculate *\/\n\t\t$diff\t = time() - mysql2date( 'U', $post-&gt;post_date );\n\n\t\tif ( $hours * 60 * 60 &gt; $diff ) {\n\t\t\t$args = $args . &quot;&lt;span style='padding:2px 8px;color:#fff;background:red;position: absolute;left: 15px;top: 15px;'&gt;New&lt;\/span&gt;&quot;;\n\t\t}\n\t}\n\n\treturn $args;\n}\n<\/pre>\n<p>Best regards,<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Content Views Pro helps you to select and show WooCommerce products easily without coding. To display the NEW badge for WooCommerce products, Please add this code to file functions.php in the directory of your active theme: \/\/ Content Views Pro &#8211; Display New badge for WooCommerce products add_filter( &#8216;pt_cv_field_thumbnail_image_html&#8217;, &#8216;cvp_theme_woocommerce_new_badge&#8217;, 100 ); function cvp_theme_woocommerce_new_badge( $args &hellip;<\/p>\n<p class=\"read-more\"> <a class=\"\" href=\"https:\/\/contentviewspro.com\/documentation\/article\/woocommerce-new-product-badge\/\"> <span class=\"screen-reader-text\">WooCommerce &#8211; show the &#8220;NEW&#8221; badge for latest products<\/span> Read More &raquo;<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"site-sidebar-layout":"default","site-content-layout":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","footnotes":""},"doc_category":[50],"doc_tag":[21,20],"class_list":["post-2478","docs","type-docs","status-publish","hentry","doc_category-woocommerce","doc_tag-custom-code","doc_tag-woocommerce"],"year_month":"2026-09","word_count":134,"total_views":0,"reactions":{"happy":0,"normal":0,"sad":0},"author_info":{"name":"admin1","author_nicename":"admin1","author_url":"https:\/\/contentviewspro.com\/documentation\/author\/admin1\/"},"doc_category_info":[{"term_name":"WooCommerce","term_url":"https:\/\/contentviewspro.com\/documentation\/cats\/woocommerce\/"}],"doc_tag_info":[{"term_name":"custom PHP code","term_url":"https:\/\/contentviewspro.com\/documentation\/tags\/custom-code\/"},{"term_name":"WooCommerce","term_url":"https:\/\/contentviewspro.com\/documentation\/tags\/woocommerce\/"}],"_links":{"self":[{"href":"https:\/\/contentviewspro.com\/documentation\/wp-json\/wp\/v2\/docs\/2478","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/contentviewspro.com\/documentation\/wp-json\/wp\/v2\/docs"}],"about":[{"href":"https:\/\/contentviewspro.com\/documentation\/wp-json\/wp\/v2\/types\/docs"}],"author":[{"embeddable":true,"href":"https:\/\/contentviewspro.com\/documentation\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/contentviewspro.com\/documentation\/wp-json\/wp\/v2\/comments?post=2478"}],"version-history":[{"count":2,"href":"https:\/\/contentviewspro.com\/documentation\/wp-json\/wp\/v2\/docs\/2478\/revisions"}],"predecessor-version":[{"id":5372,"href":"https:\/\/contentviewspro.com\/documentation\/wp-json\/wp\/v2\/docs\/2478\/revisions\/5372"}],"wp:attachment":[{"href":"https:\/\/contentviewspro.com\/documentation\/wp-json\/wp\/v2\/media?parent=2478"}],"wp:term":[{"taxonomy":"doc_category","embeddable":true,"href":"https:\/\/contentviewspro.com\/documentation\/wp-json\/wp\/v2\/doc_category?post=2478"},{"taxonomy":"doc_tag","embeddable":true,"href":"https:\/\/contentviewspro.com\/documentation\/wp-json\/wp\/v2\/doc_tag?post=2478"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}