Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/86.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 在Wordpress中使用Timeago jQuery插件_Php_Jquery_Html_Wordpress - Fatal编程技术网

Php 在Wordpress中使用Timeago jQuery插件

Php 在Wordpress中使用Timeago jQuery插件,php,jquery,html,wordpress,Php,Jquery,Html,Wordpress,我正在尝试将timeago jQuery插件与自定义wordpress主题构建集成,以显示发布文章的时间 由于主题是使用HTML5构建的,timeago要求插入的代码看起来有点像这样: <time class="timeago" datetime="2008-07-17T09:24:17Z"></time> 显然,简单地使用是行不通的,因为时间的格式必须如上所述 非常感谢您的帮助 对于那些对解决方案感兴趣的人: 实际上,我删除了插件并将其添加到Wordpress中的

我正在尝试将timeago jQuery插件与自定义wordpress主题构建集成,以显示发布文章的时间

由于主题是使用HTML5构建的,timeago要求插入的代码看起来有点像这样:

<time class="timeago" datetime="2008-07-17T09:24:17Z"></time>

显然,简单地使用
是行不通的,因为时间的格式必须如上所述


非常感谢您的帮助

对于那些对解决方案感兴趣的人:

实际上,我删除了插件并将其添加到Wordpress中的functions.php文件中

function time_ago( $type = 'post' ) {
$d = 'comment' == $type ? 'get_comment_time' : 'get_post_time';
return human_time_diff($d('U'), current_time('timestamp')) . " " . __('ago');
}


这就是诀窍!好的,它不会实时更新,但每次页面刷新对我来说已经足够了。

老问题,但我刚刚找到了解决方案,所以对于那些仍然感兴趣的人来说

成为你的WP主题