WordPress企业主题定制/开发/优化

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

首页 » WORDPRESS主题技术 » 不使用插件显示WordPress随机文章

一般都使用插件来实现,下面是一个不用插件实现的代码:
<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.la

相关项目

  • WordPress外贸企业主题

  • 最近更新

  • 热门标签