Site icon Hip-Hop Website Design and Development

Last post in loop when even

I’m using this code to try and check the last post on each page loop is even so i can add different classes.

This works to check if its the last post :

( ( 1 == $wp_query->current_post + 1 ) == $wp_query->post_count )

This works to check if its a even post

( $wp_query->current_post % 2 == 0 )

But this doesn’t check if its the last post and even.

 ( ( 1 == $wp_query->current_post + 1 ) == $wp_query->post_count ) && ( $wp_query->current_post % 2 == 0 );

The problem i have is i want to display posts in columns and avoid the last post displaying in a column with a gap when there’s a even amount of posts.