Viewing 9 replies - 1 through 9 (of 9 total)
  • esmi

    (@esmi)

    The post_class() by itself isn’t going to be of any use unless you intend to style posts based on their categories or tags. But you could use the same approach taken by that tutorial and use <?php post_class($odd_or_even);?>

    Thread Starter nemci7v

    (@nemci7v)

    thanks esmi! Do you know how to incorporate odd and even with the post_class?

    esmi

    (@esmi)

    I gave you the code above.

    Thread Starter nemci7v

    (@nemci7v)

    I tried <div <?php post_class($odd_or_even); ?>> after the loop but that doesn’t do anything

    esmi

    (@esmi)

    You need the rest of the code from that tutorial as well.

    How would you use the following together:

    <?php post_class($odd_or_even);?>
    <?php post_class('extra');?>

    I’ve tried the following but it didn’t work:
    <?php post_class($odd_or_even,'extra');?>

    EDIT:

    I go this working with the following but I’m sure it’s a dirty way of doing this:

    <?php $odd_or_even = 'odd, extra'; ?>

    And integrating that with the code from the original tutorial above.

    I know this is an old post…but if anyone is still looking on how to integrate the both, this is a good way:

    <?php while (have_posts()) : the_post();
    // Is The Post Odd or Even?
    $odd_or_even = (‘odd’==$odd_or_even) ? ‘even’ : ‘odd’;
    ?>

    <div <?php post_class(‘class name ‘. $odd_or_even. ”); ?>>

    Enjoy!

    Thread Starter nemci7v

    (@nemci7v)

    Thanks!

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘post_class for alternating colors’ is closed to new replies.