wordpress无插件调用随机文章的方法

来自:互联网
时间:2018-08-29
阅读:

wordpress无插件调用随机文章的方法如下:

<ul> 
<?php 
global $post; 
$postid = $post->ID; 
$args = array( ‘orderby’ => ‘rand’, ‘post__not_in’ => array($post->ID), ‘showposts’ => 10); 
$query_posts = new WP_Query(); 
$query_posts->query($args); 
?> 
<?php while ($query_posts->have_posts()) : $query_posts->the_post(); ?> 
<li><a href=”<?php the_permalink(); ?>” rel=”bookmark” title=”<?php the_title_attribute(); ?>”><?php the_title(); ?></a></li> 
<?php endwhile; ?> 
</ul>
返回顶部
顶部