我正在使用一些 PHP 来显示上次使用 get_the_time
和 get_the_modified_time
函数在 WordPress 上更新博客文章的时间。但是,我无法获取在段落中内联显示的上次修改时间。
<?php
$x = get_the_time('U');
$m = get_the_modified_time('U');
if ($m != $x) {
$t = the_modified_time('F d, Y');
echo "<p class=\"lastupdated\">Updated on $t </p>";
}
?>
这是结果的屏幕截图:
最佳答案
the_modified_time
打印最后修改时间,因此它会在您打印 <p>
之前打印它。 .
相反,您需要使用get_the_modified_time
用于设置$t
,像这样:
$t = get_the_modified_time('F d, Y');
关于php - 显示帖子在 WordPress 上更新的最后日期,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5526543/