WordPress.org

Ready to get started?Download WordPress

Forums

Recent posts even/odd classes (3 posts)

  1. MLaugesen
    Member
    Posted 1 year ago #

    Hi experts,

    I've searched around for this script but i can't seem to quite figure out exactly how to do this. I need a script which shows the 5 recent post-titles, and within the script I want a li-class for the even and odd posts. Can anyone help me out? I need this for the 5 recent comments also.

    Thank you

    Martin

  2. MLaugesen
    Member
    Posted 1 year ago #

    I have found this code:

    <?php if (have_posts()) : while (have_posts()) : the_post();?>
       <div class='<?php echo (++$j % 2 == 0) ? 'evenpost' : 'oddpost'; ?>'>
          <p><?php the_content(); ?></p>
       </div>
    <?php endwhile; endif; ?>

    But this is within the loop, and that is not what I am looking for. I need the same 5 recent post-titles on every page.

  3. Peter_L
    Member
    Posted 1 year ago #

Topic Closed

This topic has been closed to new replies.

About this Topic