wp随机文章代码

wp随机文章代码,无需插件,5表示显示5篇日志,代码如下:

<?php
$rand_posts = get_posts('numberposts=10&orderby=rand');
foreach( $rand_posts as $post ) :
?>
<!--下面是你想自定义的Loop-->
<li><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li>
<?php endforeach; ?>


Comment