WordPress.org

Ready to get started?Download WordPress

Forums

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

  1. gerg
    Member
    Posted 8 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?

    TIA,

  2. Joshua Sigar
    Member
    Posted 8 years ago #

    Inside the Loop...

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

  3. gerg
    Member
    Posted 8 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>';
    print_r($wp_query);
    echo '</pre>';

    That'll show you the contents. ;)

  5. gerg
    Member
    Posted 8 years ago #

    Ahhh, making sense now!

    Thanks Viper007Bond

Topic Closed

This topic has been closed to new replies.

About this Topic