Pagination on a custom page template
I have set up a custom post type called 'Events'. For reasons that I'm not going to get into, I chose not use archive-events.php
as the archive template for my Events. Instead, I decided to create a custom page template, page-upcoming-events.php
, to use as an archive.
I wrote a custom query in this template to pull in events. I am also limiting posts_per_page to 4. I've successfully added pagination links using the previous_posts_link()
and next_posts_link()
functions.
These functions are generating links to the expected urls: /upcoming-events/page/2/, etc.
On page 1, I get the first 4 events and the next events link.
The issue I'm having is that when I go to page 2, I get a 404 error, not events 5-8.
How do I add properly add pagination to a custom page template?
Topic page-template pagination custom-post-types Wordpress
Category Web