且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

在 Wordpress 站点上显示上次修改日期

更新时间:2023-02-14 21:19:04

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

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.