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 <div class="divider"></div>
:
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)
get_template_part( 'template-parts/content', 'newsandevents' );
?include(locate_template('template-parts/content-newsandevents.php'));
get_template_part
. Some people use the simplest themes in the old manner.:last
css selector instead?