• Hi Guys,

    I just started using WordPress. Currently you can view my WordPress site here:

    http://christopherlei.com/portfolio/

    The issue I am currently running into is as you can see is that after every four posts, starts a new row. However, I am running into a floating issue. My question is, how can I insert the following code below after every four posts?

    <div style=”clear: both;”></div>

    Therefore, Post 1 should be under Post 5.

    Thanks!

Viewing 4 replies - 1 through 4 (of 4 total)
  • using a counter variable in the loop?

    principle:

    if (have_posts()) :
    $counter = 0;
       while (have_posts()) :
          the_post();
          the_content();
    $counter++; if($counter%4 == 0) {
    echo '<div style="clear: both;"></div>';
    }
       endwhile; endif;
    Thread Starter vtaznboylei

    (@vtaznboylei)

    Hi Alchymyth,

    If it’s not too much trouble, is it possible to help me where you input that code above. I thought it would make sense to put the first part of that code on line 57. But I think I am putting the endwhile; endif; in the wrong spot. Here is a link to my loop.php.

    http://dl.dropbox.com/u/3713872/loop.php

    Thanks in Advance!

    you won’t need to add the endif; and endwhile; anywhere, as they should already be part of your loop.

    the only new code is:
    $counter = 0;
    (which you could put anyhwere before the while( have_posts() ) of the loop;

    and:

    $counter++; if($counter%4 == 0) {
    echo '<div style="clear: both;"></div>';
    }

    which you add directly after the closing div </div> of your post.

    however, if this explanation does not help, can you repost the code of your loop.php using a http://wordpress.pastebin.com/ as i personally just don’t download code snippets to check them.

    Thread Starter vtaznboylei

    (@vtaznboylei)

    Hi Alchymyth,

    It worked! Thank you for the help!

    Have a good rest of the day 🙂

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Setting up a clear: both after x amount of posts’ is closed to new replies.