I have a post type called journal and on the single-journal.php template I am querying the rest of the journal posts like so:

<?php query_posts( array(
     'posts_per_page' => 4,
     'post_type' => 'journal',
     'paged' => ( get_query_var('page') ? get_query_var('page') : 1 ),

This works great but displaying the navigation: <?php posts_nav_link(' ',' ','load more posts +'); ?> is linking to /journal/POST_TITLE_HERE/page/2 where I want to display /journal/page/2 (as it shows on the journal-archive.php template), if this is at all possible? Any suggestions would be greatly appreciated!

  • try to add this line : wp_reset_query(); before query_posts(); it will reset the query. – Waseem Abu Senjer Aug 24 '14 at 13:48
  • @WaseemAbuSenjer still doesn't work, still displays /journal/POST_TITLE_HERE/page/2 instead of /journal/page/2 as I'd like it to – user1374796 Aug 24 '14 at 15:29

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:

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.