Forums

[resolved] post_class() and <?php echo $odd_or_even; ?> (3 posts)

  1. jolijo
    Member
    Posted 2 years ago #

    I'm using http://adambrown.info/b/widgets/easy-php-tutorial-for-wordpress-users/posts-that-have-alternating-colors/ but I don't really know php so I don't know how to combine it with post_class() since it generates class="".

    Currently I'm using double divs:
    <div <?php post_class() ?>>
    <div class="<?php echo $odd_or_even; ?>">

    But I'd like to combine them so I only have to use one div.

    Any thoughts? :)

  2. alchymyth
    The Sweeper
    Posted 2 years ago #

    codex:
    http://codex.wordpress.org/Template_Tags/post_class

    For special cases where you want to add your own classes, post_class supports that too:

    <?php post_class('special'); ?>

    that would translate in your case into:

    <div <?php post_class($odd_or_even); ?>>
  3. jolijo
    Member
    Posted 2 years ago #

    Thanks!

Topic Closed

This topic has been closed to new replies.

About this Topic