Reputation: 27
In WooCommerce I would like to display products modified date on every product on archive pages as shop.
Any track is helpful.
Upvotes: 0
Views: 5181
Reputation: 254492
The following will display the product modified date on shop and archive pages (see date format):
add_action( 'woocommerce_after_shop_loop_item', 'after_shop_loop_item_action_callback', 20 );
function after_shop_loop_item_action_callback() {
global $product;
echo '<br><span class="date_modified">' . $product->get_date_modified()->date('F j, Y, g:i a') . '</span>';
}
Code goes in function.php file of your active child theme (or active theme). Tested and works.
Upvotes: 1
Reputation: 1
Paste that code in function.php
function show_last_modified_date( $content ) {
$original_time = get_the_time('U');
$modified_time = get_the_modified_time('U');
if ($modified_time >= $original_time + 86400) {
$updated_time = get_the_modified_time('h:i a');
$updated_day = get_the_modified_time('F jS, Y');
$modified_content .= '<p class="last-modified">This post was most recently updated on '. $updated_day . '</p>';
}
$modified_content .= $content;
return $modified_content;
}
add_filter( 'the_content', 'show_last_modified_date' );
Upvotes: 0