WordPress获取文章发表时间标签:get_the_time

本站正在使用的主机

本站目前托管于腾讯云香港轻量服务器,价格便宜访问速度也快,使用本站推荐链接购买还可免费获得WordPress运行环境优化服务。

最新活动 »

WordPress模板标签get_the_time获取当前文章的发表时间,与the_time()函数的区别在于get_the_time()函数只返回获取到的值,而the_time()函数直接输出结果。该函数需要用在The Loop主循环中。

get_the_time( string $d = '', integer/object $post = null )

函数参数

$format

字符串值,默认为WordPress后台常规设置中的时间格式

时间格式

$post

整数型或对象,默认值:当前文章ID

指定一个文章ID或包含文章信息的对象

函数使用示例

<?php echo get_the_time('', $post->ID); ?>

扩展阅读

get_the_time()函数位于:wp-includes/general-template.php

相关函数:

背字根微信二维码

本站文章均为原创,码字非常不容易,转载请注明原文出处,给苦逼的作者保留一点创作动力。