Support » Plugins » How to check if this is last post on page?

  • Hello, on my blog index page each post (article) has a bottom-border set to visually separate it from next article under it, I do not want this border to show for last post since is last one and it has page bottom line.

    How can I find if current post is last post so that I set a different CSS style for it?

    Thank you.
    – Adrian.

Viewing 1 replies (of 1 total)
  • whooami



    if you have a set number of posts on your index.php page you can do it like this, lets assume you have three (3)

    before your loop starts do this:

    <?php $postnum = 1; ?>

    Before your loop stops do this:

    <?php $postnum++; ?>

    you can do this now, this is JUST one example:

    <?php if ($postnum ==3) { ?>
    <div class="post-3" id="post-<?php the_ID(); ?>">
    <?php } else { ?>
    <div class="post" id="post-<?php the_ID(); ?>">
    <?php } ?>

    you have now assigned a different class to post #3

Viewing 1 replies (of 1 total)
  • The topic ‘How to check if this is last post on page?’ is closed to new replies.