• Resolved Brandora

    (@brandora)


    say i have 3 posts and i’m displaying them. i want to add a <hr> under each one on 2 conditions.
    1. if there is only 1 post being displayed do not show the <hr>
    2. if there is more than 1 posts displayed show it between them but not on the last one.

    i always want the last returned post to NEVER display the hr under it.

    i have this working in the loop.php page like this

    if(($count >= 1) && (($wp_query->current_post +1) !== ($wp_query->post_count))) {

    but i’m not sure how to make it work in my custom theme file using this plugin. any advice?

    • This topic was modified 9 years, 8 months ago by Brandora.
Viewing 1 replies (of 1 total)
  • Thread Starter Brandora

    (@brandora)

    well nevermind i found my answer.

    if(($count >=1) && (($count) != ($this->catlist->get_posts_count()))) { 
     $lcp_display_output .= '<hr>';
    }

    key here is to use $this->catlist->get_posts_count() to get the current post count. may be useful for others wanting to do similar things.

Viewing 1 replies (of 1 total)

The topic ‘check for last post in while loop?’ is closed to new replies.