0

早上好,我发现自己有点进退两难了!我正在使用 Twitter Bootstrap 创建一个 Wordpress 主题,我正在通过 Wordpress“帖子”为“认识团队”页面生成成员我只能在 1 行中放置 3 个条目... IE

<div class="row">
    <div class="span4"></div>
    <div class="span4"></div>
    <div class="span4"></div>
</div>

但是每行超过 3 个条目会破坏该行,所以我需要为每 3 个条目生成一个新行。我怎样才能做到这一点?

这是我用于输出条目的 PHP 代码。

<?php query_posts('category_name=members&orderby=date'); ?>
<div class="row-fluid">
   <ul class="thumbnails">
      <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
      <li class="span4">
          <div class="thumbnail">
          <?php // check if the post has a Post Thumbnail assigned to it.the_post_thumbnail();
          ?>
              <div class="pad">
                 <h3><?php the_title(); ?></h3>
                 <?php the_content(); ?>
              </div>
          </div>
       </li>
    <?php endwhile; ?>
     </ul>
  </div>
<?php endif; ?>
4

1 回答 1

0

尝试这个

<?php query_posts('category_name=members&orderby=date'); ?>
<div class="row-fluid">
   <ul class="thumbnails">
      <?php 
      $cnt =0;
      if ( have_posts() ) : while ( have_posts() ) : the_post(); 
        if($cnt%3==0){
          echo "</ul></div><div class='row-fluid'><ul clsas='thumbnails'>";
        }

      ?>
      <li class="span4">
          <div class="thumbnail">
          <?php // check if the post has a Post Thumbnail assigned to it.the_post_thumbnail();
          ?>
              <div class="pad">
                 <h3><?php the_title(); ?></h3>
                 <?php the_content(); ?>
              </div>
          </div>
       </li>
    <?php 
    $cnt++;
    endwhile; ?>
     </ul>
  </div>
<?php endif; ?>
于 2013-03-21T11:00:25.903 回答