• Resolved get_username

    (@get_username)


    I’m trying to figure out which page template is being used when I click on my previous_posts_link or next_posts_link on a page template and category template?

    For my blog page template it successfully pulls my (page-blog.php) template and I’m able to click back and forth without issue.

    When I click on a category page it successfully pulls my (category.php) template, but when I go to a sub-category and click on the next or previous links, it automatically takes me to (index.php). It doesn’t go through my list of categories like it does on the blog page.

Viewing 6 replies - 1 through 6 (of 6 total)
  • This happens when the posts have multiple categories, the next prev links go to the current post’s first category.

    WP-PageNavi resolves this.

    Thread Starter get_username

    (@get_username)

    Is there any way to resolve this without a plugin? In not doing anything outside the normal usage of WordPress.

    My solution was above, maybe another can help with some custom PHP.

    Thread Starter get_username

    (@get_username)

    Thanks for the replay. I guess I’m not understanding why this wouldn’t work with WordPress built-in features? I’m not doing anything custom and am only adding what WordPress suggests to use when navigating a page.

    An update to my original posts shows that my blog page no longer works either. If I click on the Next page link(next_posts_link) it still shows the first page posts. It is no longer specific to categories.

    I would at least like to learn what I’m doing wrong, and find out the limitations to WordPress before installing a plugin to complicate matters. Hope you can understand that.

    Thread Starter get_username

    (@get_username)

    So after a little more searching I did find this, and it works with my blog section. Apparently you have to input this into your query. Unfortunately, all the WordPress books I have been reading do not mention this. It is, however, hidden within the WordPress query_posts documentation under subhead Pagination.

    query_posts( array( 'cat' => 8, 'paged' => get_query_var('paged') ) );

    I will test this when I’m on my categories page and see if it does the same thing.

    Thread Starter get_username

    (@get_username)

    This issue has been resolved. I tested the code above on a category page and it works there as well. No need for a plugin as I believe it’s just a matter of calling the correct query. Glad I figured this one out, as these forums are pretty quiet when it comes to help.

    Hopefully this helps others that might have the same problem.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Previous & Next links use different templates for pages and categories’ is closed to new replies.