问题
I'm looking for solution to display products published date on shop page.
I would very greatful for any help.
回答1:
Show Product Published Date Shop and Single Page in WooCommerce
add the below function in function.php file
//WooCommerce Shop Page : Show Product Published Date
add_action( 'woocommerce_after_shop_loop_item', 'wc_shop_page_product_date', 100 );
function wc_shop_page_product_date() {
echo the_date('', '<span class="date_published">Published on: ', '</span>', false);
}
//WooCommerce Single Page : Show Product Published Date
add_action('woocommerce_single_product_summary','wc_single_page_product_date',25);
function wc_single_page_product_date() {
if (is_product() ) {
echo the_date('', '<span class="date_published">Published on: ', '</span>', false);
}
}
回答2:
add_action('woocommerce_single_product_summary','show_product_date',28);
function show_product_date() {
if (is_product() ) {
echo the_date('', '<p class="product_date">Published on: ', '</p>', false);
}
}
来源:https://stackoverflow.com/questions/44627695/woocommerce-show-product-published-date-on-shop-page