WordPress.org

Ready to get started?Download WordPress

Forums

end of category.php producing 404 error (8 posts)

  1. nickbudden
    Member
    Posted 3 years ago #

    Hi,

    I'm having a problem with my category.php template. When I read the end of my posts, i.e. when there are still a few posts but not enough to fill up a category page, it spits out a 404 error rather than showing those last few posts and just stopping to go backwards. You can see this here if you click 'next' at the bottom of the page: http://pixelbang.com/travel/category/blog/

    I haven't been able to figure this out. Would anybody have any ideas as to why I get a 404?

    Thanks

  2. esmi
    Forum Moderator
    Posted 3 years ago #

    Does the template use a custom query (eg query_posts())?

  3. nickbudden
    Member
    Posted 3 years ago #

    Yes it uses the following query that I got off these forums. I use it to limit the number of posts per page for different categories:

    <?php if (is_category('CATEGORY-NAME')) { $posts = query_posts($query_string . '&orderby=date&showposts=3'); } ?>

  4. esmi
    Forum Moderator
    Posted 3 years ago #

    Try changing it to:

    <?php if (is_category('CATEGORY-NAME')) {
    $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
    $posts = query_posts($query_string . '&orderby=date&posts_per_page=3&paged =' .$paged ); }
    ?>
  5. nickbudden
    Member
    Posted 3 years ago #

    Thanks, but no luck, it is still producing a 404. Would there be another way to limit posts per page? Or another way to have multiple loops on a category page, i.e. without using wp_reset_query (which I assume breaks the category)

  6. esmi
    Forum Moderator
    Posted 3 years ago #

    The method you're using is the one I'd suggest. Assuming you're using a custom permalink structure, does the problem still occur with default permalinks?

    If you remove the custom query and limit the posts per page to via Settings/Reading, does it still happen?

  7. nickbudden
    Member
    Posted 3 years ago #

    Hi, sorry for the delay but finally got a change to test it out. If I remove the query and set the posts per page via admin settings it works fine, and if i put the query back in there while disabling my custom permalinks it also works fine.

    Any suggestions on how to incorporate this along with my custom permalinks? I've really got my heart set on them.

  8. nickbudden
    Member
    Posted 3 years ago #

    If anyone runs into this same problem set your posts per page to 0, and check out this thread: http://wordpress.org/support/topic/fix-for-the-previousnext-entry-link-problem?replies=1

Topic Closed

This topic has been closed to new replies.

About this Topic