WordPress.org

Ready to get started?Download WordPress

Forums

Alternating div's for posts (2 posts)

  1. MaddTechWF
    Member
    Posted 3 years ago #

    I have my page setup with the typical <?php if(have_posts()) : while(have_posts()) : the post() ?><?php endwhile; endif; ?> but I have a two DIV's inside this loop that needs to alternate. How could I do this with as little as code as possible.

  2. MaddTechWF
    Member
    Posted 3 years ago #

    Current code. I want to show 2 posts per row.

    <?php if(have_posts()) : while(have_posts()) : the_post(); ?>
        <div class="posts">
            <div class="row">
                <div class="first">
                   <h2><?php the_title(); ?></h2>
                   <?php the_content(); ?>
                </div>
                <div class="second">
                   <h2><?php the_title(); ?></h2>
                   <?php the_content(); ?>
                </div>
            </div>
        </div>
    <?php endwhile; endif; ?>

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.