Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Although I would create a code differently, the solution to your problem I believe is to modify your code to this:</p> <pre><code>&lt;?php get_header(); ?&gt; &lt;section class="clearfix" id="home"&gt; &lt;?php $count = 1; ?&gt; &lt;?php if ( have_posts() ) : ?&gt; &lt;?php while ( have_posts() ) : the_post(); ?&gt; &lt;?php if($count % 2 == 0) { &lt;div class="row-fluid"&gt; }?&gt; &lt;div class="span4"&gt; &lt;div class="wrap-title"&gt; &lt;div class="position"&gt; &lt;div class="title"&gt;&lt;?php the_title();?&gt;&lt;/div&gt; &lt;div class="tags"&gt;&lt;?php echo $cats; ?&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;?php if($count % 2 == 0) { echo '&lt;/div&gt;'; }?&gt; &lt;?php $count++; ?&gt; &lt;?php endwhile; ?&gt; </code></pre> <p><strong>EDIT:</strong></p> <p>You said it produces 2 posts after also - that is why you will add <code>&lt;/div&gt;</code> after first two posts, and then after that you will continue printing. The solution would be to use the code above - with <code>%</code> <strong>or</strong> to print only two posts use this code:</p> <pre><code>&lt;?php get_header(); ?&gt; &lt;section class="clearfix" id="home"&gt; &lt;div class="row-fluid"&gt; &lt;?php $count = 1; ?&gt; &lt;?php if ( have_posts() ) : ?&gt; &lt;?php while ( have_posts() ) : the_post(); ?&gt; &lt;div class="span4"&gt; &lt;div class="wrap-title"&gt; &lt;div class="position"&gt; &lt;div class="title"&gt;&lt;?php the_title();?&gt;&lt;/div&gt; &lt;div class="tags"&gt;&lt;?php echo $cats; ?&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;?php if($count == 2) { break; }?&gt; &lt;?php $count++; ?&gt; &lt;?php endwhile; ?&gt; &lt;/div&gt; </code></pre> <p>But the above code could be optimized not to search for all posts, but it should will work as is.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload