I have a custom post type (gallery). On the archive page, I'm limiting the display to 12 items, with pagination links below. This works as it should, but I'm getting error notices:
Notice: Undefined variable: query in /var/www/wp-content/themes/sal-custom_strap/archive-gallery.php on line 78
Notice: Trying to get property 'max_num_pages' of non-object in /var/www/wp-content/themes/sal-custom_strap/archive-gallery.php on line 78
Here is the code (line 78 is the second to last line) :
<div class="card-deck justify-content-center" id="gallery-results">
<?php
while ( have_posts() ) :
the_post();
get_template_part( 'template-parts/content', 'gallery' );
endwhile; // End of the loop.
?>
</div><!-- .card-deck -->
<div class="nav-center">
<div class="nav-next"><?php previous_posts_link( '<–– Previous' ); ?></div>
<div class="nav-previous"><?php next_posts_link( 'Next ––>', $query->max_num_pages ); ?></div>
</div>
I wrote this code a while ago and haven't been using php since, so I suspect I am forgetting something basic. What am I missing?
thanks.