Display post divider in between post in WordPress

Well, adding a divider between the posts makes it more clear and gives orderly look. Here is the snippet to add a divider between the posts skipping the last post.

if (($wp_query->current_post + 1) < ($wp_query->post_count)) {
   echo '<div class="post-item-divider">Post Divider</div>';
}

In the above code, we are adding condition if the current post + 1 is lesser than the number of the post count then we are simply printing the divider.

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top