I am creating a child theme archive template. I don’t know how many posts will be displayed, which is fine except that i want to have a dividing line after each post except the last one.

I am using the usual loop, have added a $loopcount variable, and then an include to create the formatting/display and add the

:

while ( have_posts() ) : the_post();
$loopCount++;
include(locate_template('template-parts/content-newsandevents.php'));
endwhile;

I have looked in the codex but I can’t find a way to know how many posts the loop is going to do in advance. (I could use jQ to do this, but it would be neater to do it with php I think)

Read more here: How many posts does the loop return?


Solution:

If you know the solution of this issue, please leave us a reply in Comment section, to update the question.


Wordpress related questions and answers: