I am developing a WordPress theme and want to determine if I am at the last post of the current loop page.
<?php get_header(); ?>
<main id="main">
<!-- ======= Blog Grid ======= -->
<section class="news-grid grid">
<div class="container">
<?php if (have_posts()) : ?>
<?php $counter= 0 ?>
<?php while (have_posts()) : the_post(); ?>
<?php if ($counter==0): ?>
<div class="row">
<?php endif; ?>
<?php $counter++; ?>
<?php the_content(); ?>
<?php if ($counter==3 || get_previous_post() == "" /* or its the last post this loop page */ ): ?>
</div> <!-- close row -->
<?php $counter=0; ?>
<?php endif; ?>
<?php endwhile; endif; ?>
</div>
</section><!-- End Blog Grid-->
</main><!-- End #main -->
<?php
get_footer(); ?>