2014-01-10 37 views
0

我有一段代码来显示帖子下的随机文章。但是这段代码只显示了该帖子的作者写的帖子。 什么错了?WordPress的随机邮政编码只显示一个作者的帖子

<?php $posts = get_posts('orderby=rand&numberposts=3'); foreach($posts as $post) { ?> 
     <div class="col-sm-12 col-md-6 col-xs-12 col-lg-4"> 
      <div class="thumbnail"> 
       <article> 
        <a href="<?php the_permalink();?>"><?php the_post_thumbnail('photo-thumbnail') ?></a> 
        <div class="caption"> 
         <a href="<?php the_permalink();?>"> 
          <h3 style="font-weight:bold; margin-top: 0px; line-height: 1.3;"><?php the_title(); ?></h3> 
         </a> 
        </div> 
       </article> 
      </div> 
      <div class="thumbnailFooter"> 
       <div class="pull-left" style="margin-bottom: 4px;"><?php echo get_avatar(get_the_author_meta('ID'), 32); ?></div> 
       <div class="smallFont pull-left" style="margin-left: 5px; width: 240px;"><span class="blue bold"><?php the_author(); ?></span></div> 
       <div class="verySmallFont pull-left" style="margin-left: 5px; margin-top: -3px;">en <span class="bold gray"><?php the_category(none); ?></span> el <?php the_time('j F, Y'); ?> </div> 
      </div> 
     </div> 
     <?php } ?> 
+0

我相信这是因为你的global_query的它最初选择的作者和它拿起的一个随机岗位作者。所以,我会重置您想要随机文章/文章的部分的查询并创建新的查询。 – Ljubisa

+0

如何重置查询? :) –

+0

我用<?php wp_reset_query(); ?>在循环endif后但不起作用 –

回答

相关问题