在微博上,你的每条微博下面都会有“XX分钟前”这个提示,有的朋友使用插件在WordPress上也实现了这个功能,但是能用代码我们何必还使用插件呢,今天分享如何使用代码实现这个功能。首先在functions.php中添加如下代码: function time_ago_comment( $type = 'post' ) { $d = 'comment' == $type ? 'get_comment_time' : 'get_post_time'; return human_time_diff($d('U'), current_time('timestamp')) . " " . __('ago');} 然后在single.php或者index.phpzhong 添加下面的代码