显示WordPress随机文章(不使用插件)

前端之家收集整理的这篇文章主要介绍了显示WordPress随机文章(不使用插件)前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

通常我们可以通过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啦编译

猜你在找的wordpress相关文章