【问题标题】:Wordpress - Check if post has updateWordpress - 检查帖子是否有更新
【发布时间】:2015-07-31 21:14:34
【问题描述】:

如何在 Wordpress 中检查帖子是否已更新?

if (post_has_edit())
    the_modified_time();
else
    the_time();

post_has_edit()这样的功能吗?

【问题讨论】:

  • if (last edit date <> creation date),可能
  • 是函数o_O吗?
  • 你能说一下你的意思吗?

标签: php wordpress last-modified


【解决方案1】:

From the Wordpress docs:

如果帖子或页面尚未修改,则修改时间与创建时间相同。

所以你可以使用the_modified_time(),如果帖子没有被修改,它会返回创建时间。

查看帖子是否被修改,查看the_modified_time() == the_time()是否。

【讨论】:

  • the_modified_time() == the_time() 应该是get_the_time() == get_the_modified_time()
  • 如果帖子是作为草稿发布的,get_the_time() 将是当前时间,get_the_modified_time() 将是帖子首次进入草稿的时间。
【解决方案2】:

如果您需要在同一页面(例如:存档页面、搜索页面或任何WP_Query)上查看多个帖子date,您可以使用

if(get_the_modified_date == get_the_date) :

    // Do stuff here

endif;

记住使用!= 表示不相等:)

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-09-11
    • 1970-01-01
    • 1970-01-01
    • 2017-04-06
    • 1970-01-01
    相关资源
    最近更新 更多