Ready to get started?Download WordPress


[resolved] Knowing the last post in the loop? (5 posts)

  1. gerg
    Posted 9 years ago #

    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?


  2. Joshua Sigar
    Posted 9 years ago #

    Inside the Loop...

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

  3. gerg
    Posted 9 years ago #

    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>
    <? } ?>

  4. echo '<pre>';
    echo '</pre>';

    That'll show you the contents. ;)

  5. gerg
    Posted 9 years ago #

    Ahhh, making sense now!

    Thanks Viper007Bond

Topic Closed

This topic has been closed to new replies.

About this Topic