通过代码实现wordpress随机文章显示

网站建设评论1,903

鉴于wordpress的开源性,网上已经有很多的插件可以调用显示wordpress的随机文章,但是还是那句话插件用的多了,你的博客反应速度必然会受到一定的影响。

其实你如果想调用显示wordpress随机文章,只需在相应位置放入以下代码即可:文章源自堕落的鱼-https://www.duoluodeyu.com/577.html

<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>文章源自堕落的鱼-https://www.duoluodeyu.com/577.html

文章源自堕落的鱼-https://www.duoluodeyu.com/577.html文章源自堕落的鱼-https://www.duoluodeyu.com/577.html
 最后更新:2011-5-6
匿名

发表评论

匿名网友
确定

拖动滑块以完成验证