将以下代码加入functions.php中
//添加最新更新文章
function wpb_lastupdated_posts() {
// Query Arguments
$lastupdated_args = array(
'orderby' => 'modified',
'ignore_sticky_posts' => '1'
);
//Loop to display 5 recently updated posts
$lastupdated_loop = new WP_Query( $lastupdated_args );
$counter = 1;
echo '<ul>';
while( $lastupdated_loop->have_posts() && $counter < 7 ) : $lastupdated_loop->the_post();
echo '<li>   <a href="' . get_permalink( $lastupdated_loop->post->ID ) . '"> ' .get_the_title( $lastupdated_loop->post->ID ) . '</a><br>    ( 更新时间:'. get_the_modified_date('Y.m.d G:i') .') </li>';
$counter++;
endwhile;
echo '</ul>';
wp_reset_postdata();
}
//add a shortcode
add_shortcode('lastupdated-posts', 'wpb_lastupdated_posts');
现在就可以在wordpress主题模版中使用下面的方式显示最新更新的文章了:
<?php if (function_exists(wpb_lastupdated_posts)) : wpb_lastupdated_posts(); endif; ?>
如果不想修改wordpress主题模版文件,也可以直接在文章、页面、小工具里直接添加简码:
[lastupdated-posts]


![[记录]成都信息工程大学打卡登录操作](https://cdn.jysafe.cn/assets/images/pics/028.webp!githumb3.jpg)
![[记录]Github接入认证更新V3 Authorization HTTP](https://cdn.jysafe.cn/wp-content/uploads/2020/02/2020021013514870.png!githumb3.jpg)
![[WordPress插件]QQ微博百度GitHub微信登录插件 正式版](https://cdn.jysafe.cn/wp-content/uploads/2017/08/2020020515011360.png!githumb3.jpg)

