Recent posts even/odd classes (3 posts)

  1. MLaugesen
    Posted 3 years 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


  2. MLaugesen
    Posted 3 years 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>
    <?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
    Posted 3 years ago #

Topic Closed

This topic has been closed to new replies.

About this Topic