WordPress.org

Ready to get started?Download WordPress

Forums

Odd and even posts ... (3 posts)

  1. thornomad
    Member
    Posted 8 years ago #

    Hi,

    I wanted to format every other post differently -- how can I easily determine if the post is an "odd" post or and "even" post so I can have two different div classes that respond accordingly?

    Thanks.

  2. Austin Matzko
    Member
    Posted 8 years ago #

    Have a variable within the "Loop" alternate.

    if ('class1' == $alternate) $alternate = 'class2';
    else $alternate = 'class1';
    . . .
    <div class="<?php echo $alternate; ?>">
    <?php the_content(); ?>
    </div>

  3. thornomad
    Member
    Posted 8 years ago #

    That is genius; thank you!

    D

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.