Php 在Woocommerce商店页面上显示每个产品的修改日期

Php 在Woocommerce商店页面上显示每个产品的修改日期,php,wordpress,date,woocommerce,product,Php,Wordpress,Date,Woocommerce,Product,在WooCommerce中,我想在存档页面上的每个产品上显示产品的修改日期,如shop 任何轨道都是有用的 将该代码粘贴到function.php中 函数显示上次修改日期($content){ $original_time=获取_时间('U'); $modified_time=get_the_modified_time('U'); 如果($modified_time>=$original_time+86400){ $updated_time=get_the_modified_time('h:ia

在WooCommerce中,我想在存档页面上的每个产品上显示产品的修改日期,如shop

任何轨道都是有用的

将该代码粘贴到function.php中

函数显示上次修改日期($content){
$original_time=获取_时间('U');
$modified_time=get_the_modified_time('U');
如果($modified_time>=$original_time+86400){
$updated_time=get_the_modified_time('h:ia');
$updated_day=获取修改后的时间('fjs,Y');
$modified_content.='

这篇文章最近一次更新是在“$updated_day”。

”; } $modified_content.=$content; 返回$modified_内容; } 添加过滤器(“内容”、“显示上次修改日期”);
以下内容将在商店和归档页面上显示产品修改日期(请参阅):

add_action('woocommerce_在_shop_loop_item之后,'woocommerce_在_shop_loop_item之后,'woocommerce_在_shop_loop_item_action_callback之后,'20');
函数在\u shop\u loop\u item\u action\u callback()之后{
全球$产品;
回显“
”.$product->get_date_modified()->date('fj,Y,g:ia'); }
代码进入活动子主题(或活动主题)的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' );
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>';
}