Skip to content
Advertisement

Display the published date of every product on Woocommerce shop page

I’m looking for solution to display products published date on shop page.

I tried the following code, but it show only for first product

Any help will be greatful

JavaScript

Advertisement

Answer

the_date function assumes you are inside a loop that is properly setting up the post data, which in your case seems not to be done. You could manually provide the product id using $product object and use get_the_date() function instead.

Below is the solution that should do for you:

JavaScript

Here is a guide on customizing the date format: codex.wordpress.org/Formatting_Date_and_Time

User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement