I remember in another theme I did, that the The Loop automatically looped for the number that was set in "Blog pages show at most" (Settings->Reading). The theme I am working on right now does not see to consider this number and loops for an infinite amount of time (and crashes of course). How do I make it to consider "Blog pages show at most" ?
The only reasonable guesses that come to my mind are that the theme (or a plugin):
- Modifies the main Query with a filter on
pre_get_posts, so look for that filter.
- Just creates a new Loop with
new WP_Query($args). You will have to dig through the template file to find out.
- Interrupts the
post_per_pagesave process or alter the
posts_per_pageoption in the database, so check the
*_optionstable for the
posts_per_pagekey (option_name) to rule that out.
- The Loop is not calling
the_post. Without that, the Loop will never increment to the next post and the loop will run until the browser gives up.
I'd bet on #1, then #2, with #3 being a distant third. Without more information I can't give a solid answer.
Item #4 is a very viable option but the problem is not the query itself but the Loop.
I just ran into this problem using pagination (not infinite loop). It seems that the "Blog pages show at most" controls how many total pages are available and does not realize how many posts are actually being shown....
For instance, if my category has 113 posts, and I show 10 results per page (using $args(posts-per-page = 10)) I should expect to have 11 pages... but since my "Blog pages show at most" is set to 20, I only have 6 pages available. This is what I figured out:
PAGE RESULTS EXPECTED RESULTS GIVEN 1 POSTS #1-10 POSTS #1-10 2 POSTS #11-20 POSTS #21-30 3 POSTS #21-30 POSTS #61-70 4 POSTS #31-40 POSTS #81-90 5 POSTS #41-50 POSTS #101-113 6 POSTS #51-60 404 Error 7 POSTS #61-70 404 Error 8 POSTS #71-80 404 Error 9 POSTS #81-90 404 Error 10 POSTS #91-100 404 Error 11 POSTS #101-113 404 Error
As you can realize, I had a lot of posts missing from my list, and since my posts aren't numbered, it was difficult to figure out.
How to fix: Set your "Blog pages show at most" to a number LOWER than your lowest post-per-page. That way, Wordpress will allot enough pages for your query to complete... otherwise, you will get an error because the total pages expected by the plugin or your own code will exceed what Wordpress believes you should have.