在 Wordpress 站点上显示上次修改日期 [英] Display last modified date on a Wordpress site

查看:32
本文介绍了在 Wordpress 站点上显示上次修改日期的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道是否有人知道在 Wordpress 网站上显示上次修改日期的有效方法.

I was wondering if anyone knows an effective way of displaying the last modified date on a Wordpress site.

我对单个帖子或页面的上次修改日期不感兴趣,但对显示最后一次在网站上进行任何修改的日期(可能还有时间)感兴趣.

I'm not interested in the last modified date of a single post or page, but in a date (and maybe time) that shows the last time ANY modification was made on a site.

例如:

  • 我修改了 18 年 9 月 15 日的Hello World"帖子
  • 我在 18 年 9 月 16 日修改了示例页面"页面
  • 我上次修改"在Hello World"帖子上显示16/09/18",并且也在示例页面"页面上.

我知道 the_modified_date()get_the_modified_date() 函数,但我想有效显示所有修改后的内容(页面、帖子、自定义帖子类型等)

I'm aware of the the_modified_date() and the get_the_modified_date() functions, but I'd like to effectively show the latest from all of the modified content (pages, posts, custom post types, etc.)

提前感谢您的建议!

推荐答案

您可以查询最近更新的帖子和页面,然后从中提取更新日期.尝试这样的事情.

You could query the most recently updated posts and pages, then pull out the updated date from there. Try something like this.

$recently_updated_posts = new WP_Query(array(
    'post_type'      => array('any'),
    'posts_per_page' => 1
    'orderby'        => 'modified',
    'no_found_rows'  => true, // speed up query when we don't need pagination
));

然后,您可以在标准 WordPress 循环中使用 $recently_updated_posts 并访问 the_modified_date()get_the_modified_date() 函数.

Then, you can use the $recently_updated_posts in the standard WordPress loop and have access to the_modified_date() and the get_the_modified_date() functions.

这篇关于在 Wordpress 站点上显示上次修改日期的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆