<?php printf(__(\'%1$s at %2$s\'), get_comment_date(), get_comment_time()) ?>
以上是注释的默认代码。WP核心中的php。这将产生如下输出:
2017年10月1日上午6:58但我想要这样的东西→
发布时间:11个月前
或
3天前发布
或
23小时前发布
是否可以与这两个方面进行协作:
get_comment_date(), get_comment_time()
要达到上述效果?<?php printf(__(\'%1$s at %2$s\'), get_comment_date(), get_comment_time()) ?>
以上是注释的默认代码。WP核心中的php。这将产生如下输出:
2017年10月1日上午6:58但我想要这样的东西→
发布时间:11个月前
或
3天前发布
或
23小时前发布
是否可以与这两个方面进行协作:
get_comment_date(), get_comment_time()
要达到上述效果?您需要的是:https://codex.wordpress.org/Function_Reference/human_time_diff
因此,这应该正好满足您的需要:
<?php printf( _x( \'%s ago\', \'%s = human-readable time difference\', \'your-text-domain\' ), human_time_diff( get_comment_time( \'U\' ), current_time( \'timestamp\' ) ) ); ?>
我正在尝试将其添加到函数中。php。在我的另一个站点上的测试实验室中,它可以很好地添加测试信息。但在这个网站上,我试图把它添加到什么都没有发生的情况下。该网站正在使用最新的woocommerce运行一个建筑节俭主题。有什么想法吗?我基本上只是想在每个产品页面上添加一行类似于免责声明但无法添加的文本。add_action(\'woocommerce_before_add_to_cart_form\',\'print_something_below_short_description\');