posts_nav_link on single post template

Single pages are designed to display a single post, and not an index of posts as an archive page would. I’m not really sure what are you trying to achieve here as well.

It is always a bad idea to try and use a specific template for anything else than what it was intended for. The main query are quite specific to a specific template, in this case, the main query would be set up to query and retrieve the specific single post being queried. Single pages are not meant to be used for archive or index pages

It is for this reason that you are getting this inconsistent and non intended results. What WordPress is trying to do is to display page 2 of the current queried single post, that is why you are getting this strange URL.

There is a few point that I would like to point out as well:

  • Never use query_posts, and my emphasis, absolutely never.

Note: This function isn’t meant to be used by plugins or themes. As explained later, there are better, more performant options to alter the main query. query_posts() is overly simplistic and problematic way to modify main query of a page by replacing it with new instance of the query. It is inefficient (re-runs SQL queries) and will outright fail in some circumstances (especially often when dealing with posts pagination).

  • Never swap the main query for any type of custom query on a home page, any archive page or a single page template.

  • posts_nav_link is not meant to be used on single pages

  • Your archive page to display your custom post type should be named archive-journal.php, and not journal-archive.php. This goes against normal template hierarchy

For further reading, go and check out the following links:

Leave a Comment