WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm too angry about this problem to see it straight anymore, so I'm guaranteed to be overlooking something simple. Please help.

Here's all my code has been stripped down to:


$home_gallery = new WP_Query(array(
"posts_per_page" => 2

if ( $home_gallery->have_posts() ) : while ( $home_gallery->have_posts() ) : 


//if (get_post_meta(get_the_ID(), "_is_front_page_gallery", true) == "true") {

<?php endif; ?>

Trying to run this code on the front page of my WordPress site has causes my CPU to spike, my fan to run hot, and one of two errors to surface. Either I get a long string of "Offset = 10" errors (can't recreate that one right this minute so I can't copy/paste) or more recently I'm just getting this:

Fatal error: Maximum execution time of 30 seconds exceeded

Any ideas anyone has I would be happy to hear. It's running on my localhost and has worked fine up until this afternoon. .

The problem seems very similar to this one: Repetitive Error: Maximum Execution has exceeded 30 secs

which was closed for being unhelpful. :(

share|improve this question
It gets stranger. I removed references to $home_gallery in both have_posts() calls, to see if a standard loop would even work. Still getting the maximum 30 seconds exceeded error. This is a file called content-front.php that is getting called using the get_template_part() function called on index.php – Jason Rhodes Jun 9 '12 at 21:32
There's nothing in the code you posted that is at all unusual. The answer is probably in the context of the index.php file if you've already confirmed that a normal loop in a different theme runs OK on your WP installation. For example, are you calling that template part from within another loop? Etc. – Isaac Lubow Jun 10 '12 at 7:41
up vote 0 down vote accepted

I finally figured this out. It's simple, too.

As I posted it, that loop would never finish because there's nothing advancing the counter inside the while loop.

But if I uncomment my fairly normal-looking code and run it, it still wouldn't close, because I'm not advancing the specific Query object's counter. When you run the_post(), it advances the counter inside the global loop object and sets the global $post object, which is what will be run when you call functions like the_title() and others. So you'd run through every post in the database, because though my custom $home_gallery query object only had 5 posts, the global loop has all the posts in it.

In other words, since I didn't specifically run $home_gallery->the_post();, everything exploded.

Hope this helps someone else.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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