Forums

Four side-by-side columns in WordPress (5 posts)

  1. all_good_things
    Member
    Posted 2 years ago #

    Hi!

    Does anyone know how I according to this tutorial I can have -- not two -- but four side-by-side columns in WordPress?

    Thanks!

  2. esmi
    Theme Diva & Forum Moderator
    Posted 2 years ago #

    That tutorial is about as easy as it gets.

  3. all_good_things
    Member
    Posted 2 years ago #

    Yes, but the part where you can have four columns instead of two isn't explained here.

    Someone who knows how this is done?

  4. alchymyth
    The Sweeper
    Posted 2 years ago #

    try and replace this line:
    <?php if ($col == 1) echo "</div>"; (($col==1) ? $col=2 : $col=1); endwhile; ?>
    (which, imho, is wrong anyway and should read:
    <?php if ($col == 2) echo "</div>"; (($col==1) ? $col=2 : $col=1); endwhile; ?> )

    with this line:
    <?php if ($col == 4) { echo "</div>"; $col=0; }; $col++; endwhile; ?>
    it puts the end div after the fourth column, then resets the counter.

    untested, hope it works for you ;-)

  5. alchymyth
    The Sweeper
    Posted 2 years ago #

    edit: a comment on this http://www.cre8d-design.com/2008/03/how-to-organize-posts-into-two-side-by-side-columns-in-wordpress/
    pointing to a weakness of the presented code: it does not close the 'row' div for an uneven number of posts.

    fix:
    instead of:
    <?php if ($col == 4) { echo "</div>"; $col=0; }; $col++; endwhile; ?>

    try this:

    <?php if ($col == 4) { echo "</div>"; $col=0; }; $col++; endwhile;
    if ( $col > 1 ) { echo "</div>"; } ; ?>

    untested

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.