Support » Fixing WordPress » Pagination Issues (problematic logic explanation and suggested solutions)

  • I’ve noticed today an issue that wasn’t occurring when I originally implemented the functionality. The previous version I was running was 2.7.

    I use a custom template file (category-photos.php) to set the value of posts to show per page to 1. I noticed that at a certain point the pagination was resulting in 404 page.

    I have 100 photos. My default value (admin interface) of posts per page is set to 17. WP seems to first check if the requested page number exists using this value of 17, and if it does it loads a custom template. If it does not, the template is skipped in favor of a 404 template. My pagination was breaking at page 7.

    My solution (although hacky) is to set the value to 1 in admin interface and set the value to 17 in the case I’m loading anything, but the photo category.

    So now in index.php:

    if (is_category('photos')) {
      $query_string = $query_string . "&showposts=1";
     } else if (is_category('movies-tv')) {
      $query_string = $query_string .
     } else {
      $query_string .= "&showposts=17";

    Before the loop:

    This was definitely not the behavior before, as I mentioned earlier. If it was an intentional change or not I do not know.

    Would be nice to get an official word on this and classify it as a bug, or let it go.

  • The topic ‘Pagination Issues (problematic logic explanation and suggested solutions)’ is closed to new replies.