How to have the two last post side by side on the bottom (3 posts)

  1. taraface
    Posted 3 years ago #

    I've noticed in a lot of blogs, such as healthytippingpoint.com, katheats.com there are two of the last posts on the bottom of the main screen. I personally haven't played around with it, but my web developer guy doesn't know how to do it either. Is this a simple plug-in or maybe there is something going over our heads.


  2. Michael
    Forum Moderator
    Posted 3 years ago #

    you can use the $wp_query->current_post variable to check the position of a post in the loop (starts with 0 zero for the first post), and use this in a conditional statement to style the posts differently.
    also, to check the position from the end, you can use $wp_query->post_count which is the number of posts on that page.

    example, the second last post in the loop is (for a minimum of 4 posts on that page):

    if( $post_count >=4 && $wp_query->current_post == $post_count-2 ) echo 'second-last post';
  3. dragonsjaw
    Posted 3 years ago #

    on katheats.com it looks to me like they just used a text widget and entered the link and photo..it doesn't seem to be something that was pulled in from the loop. I could be way wrong. And it is on the bottom of each page, so I suspect she just wants to highlight these 2 posts.

Topic Closed

This topic has been closed to new replies.

About this Topic