简体   繁体   English

在Wordpress中使用Twitter Bootstrap自动生成行

[英]Auto generate row with Twitter Bootstrap in Wordpress

Good morning, I have found myself in a bit of a dilemma! 早上好,我发现自己陷入了两难境地! I am creating a Wordpress theme using Twitter Bootstrap and I am generating the members for the "Meet the Team" page via Wordpress "Posts" I can only fit 3 entries in 1 row... IE 我正在使用Twitter Bootstrap创建一个Wordpress主题,并且正在通过Wordpress“ Posts”为“ Meet the Team”页面生成成员,我只能在1行中容纳3个条目... IE

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

But anymore than 3 entries per a row will break the row, so I need to generate a new row for every 3 entries. 但是每行超过3个条目将破坏该行,因此我需要为每3个条目生成一个新行。 How can I do this? 我怎样才能做到这一点?

Here is my PHP code for outputting the entries. 这是我用于输出条目的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; ?>

Try this 尝试这个

<?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; ?>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM