WordPress 的文章查询函数 get_posts() 有个参数 orderby 指明了获取文章时的排序方式。通常我们是按照文章发布日期排序,比如 WordPress 站点首页、分类页和标签页中的文章列表。orderby 还可以是 rand,它使用 MySQL 的 RAND() 函数来确定排序参数,也就是随机排序。 随机文章代码: $args = array( 'numberposts' => 5, 'orderby' => 'rand', 'post_status' => 'publish'…