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

2010年11月13日05:05:00网站建设评论1,318

鉴于wordpress的开源性,网上已经有很多的插件可以调用显示wordpress的随机文章,但是还是那句话插件用的多了,你的博客反应速度必然会受到一定的影响。文章源自堕落的鱼-https://www.duoluodeyu.com/577.html

其实你如果想调用显示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
匿名

发表评论

匿名网友 填写信息

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定