• Resolved belalugosi

    (@belalugosi)


    I am using this code for displaying posts within a certain category.
    <?php if (have_posts()) : while (have_posts()) : the_post(); ?>

    li show something li
    <?php endwhile; else: ?>
    <?php _e(‘Sorry, no posts matched your criteria.’); ?>
    <?php endif; ?>
    For styling purposes i would like that every third displayed post to have <li class”example”> instead of
    li . Something like oddcomment function.

    Thanks in advance!

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter belalugosi

    (@belalugosi)

    Thread Starter belalugosi

    (@belalugosi)

    Found this solution on the forum.

    //<?php
    $postcount = 0;
    if (have_posts()) :
    while (have_posts()) : the_post();
    $postcount++;
    ?>

    <li class=”<?php if($postcount % 3 == 0) echo “thespecialclass”; ?>”>
    –stuff-

    • <?php endwhile; else: ?>
      You are doomed!!!
      <?php endif; ?>//

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Add a class to third, sixth, 9th, post’ is closed to new replies.