wordpress显示随机文章最简单方法

首页随机显示文章 在wordpress里面并不难,也不需要安装复杂的插件,只需要在合适的php文件里面添加如下代码,这个完全归功于wordpress的模块化结构,代码如下

 

[php]
<ul>
<?php
$args = array( ‘numberposts’ => 5, ‘orderby’ => ‘rand’ );
$rand_posts = get_posts( $args );
foreach( $rand_posts as $post ) : ?>
<li><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li>
<?php endforeach; ?>
</ul>
[/php]

wordpress 随机文章 显示的样式,你可以自己调整css样式
转自 :http://lutaf.com/16.htm

标签


Warning: error_log(/www/wwwroot/www.ctrol.cn/wp-content/plugins/spider-analyser/#log/log-0311.txt): failed to open stream: No such file or directory in /www/wwwroot/www.ctrol.cn/wp-content/plugins/spider-analyser/spider.class.php on line 2900