Support » Fixing WordPress » Knowing the last post in the loop?

  • Resolved gerg


    I’d like the last post listed to not have my normal css border separator at the bottom. This inteferes with the footer which also has the same border and I’d not like to have a double line.

    Been scratching my head researching the docs to find some function which I can use inside the WP while loop to determine when I’m on the last iteration.

    Any suggestions?


Viewing 4 replies - 1 through 4 (of 4 total)
  • Inside the Loop…

    if ($wp_query->current_post == $wp_query->post_count) :
    // I'm the last post in the Loop

    Thanks alphaoide, it is much appreciated.

    In the hours I’ve poured over the literature, I’ve never seen anything documenting exactly WHAT is contained in the $wp_query array… thank you.

    Here is what works for me:

    <?php if (($wp_query->current_post +1) != ($wp_query->post_count)) { ?>
    <div class="myRule"></div>
    <? } ?>

    echo '<pre>';
    echo '</pre>';

    That’ll show you the contents. 😉

    Ahhh, making sense now!

    Thanks Viper007Bond

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Knowing the last post in the loop?’ is closed to new replies.