通常我们可以通过Random Pages Widget插件来实现随机文章的显示,不过如果不想涉及插件,下面的代码也可以调用出随机文章哦。
<ul> <?PHP $rand_posts = get_posts('numberposts=5&orderby=rand'); foreach( $rand_posts as $post ) : ?>
<li><a href="<?PHP the_permalink(); ?>"><?PHP the_title(); ?></a></li>
<?PHP endforeach; ?>
</ul>
来源:wordpress啦编译