0

intricate grid layout

I'm currently trying to wrap the first 2 posts in a div with the video and then output the remaining posts with a div wrapped around every 3 posts, as per image.

the line

if( $wp_query->current_post < 2 ): 

i've also tried with

if($count < 2)

heres a condensed version of what i have so far: Any suggesttions would be really appreciated.

<div class="row-fluid">
    <div class="span8">
        <video></video>
    </div>
    <?php $count = 1; ?>
    <?php if ( have_posts() ) : ?>
    <?php while ( have_posts() ) : the_post(); ?>
    <?php if( $wp_query->current_post < 2 ):?>
    <div class="span4">
                   // content
    </div>
    <?php if($count % 2 == 0) {
        echo '</div><div class="row-fluid">';
    }?>

    <?php else: ?>

    <div class="span4">
        //content
    </div>
    <?php if($count % 3 == 0) {
        echo '</div><div class="row-fluid">';
    }?>
    <?php $count++;?>
    <?php endif; ?>
    <?php endwhile; ?>
    <?php echo '</div>'; ?>
</div>
<?php else : ?>
<article>default wp stuff</article>
<?php endif; ?>
3
  • why not just floating the divs correctly ?? Commented Apr 10, 2013 at 11:52
  • Im using a responsive grid system, simply floating them would break the design Commented Apr 10, 2013 at 12:28
  • I do not understand how does a responsive grind will break the design, this is exactly what a responsive grid is for ,and work like , but anyhow, if you insist, I suggest you will just use Multiple Loops Commented Apr 10, 2013 at 14:07

1 Answer 1

1

I think it's an easier solution to just echo all your content and use css (float: left) to position the content properly.

<div style="width: 900px;">
  <div style="float: left; width: 600px; height: 400px;">
      some content
  </div>
  <?php foreach($post_list as $post_item): ?>
    <div style="float: left; width: 300px; height: 200px;">
      <?= $post->getContent(); ?> or what ever you use
    </div>
  <?php endforeach; ?>
  <br style="clear: left; display: none;" />
</div>

Note that I'm not that experienced with CSS but I hope this can point you in the right direction.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.