0

I've been puzzling over this one for two days. Still can't figure it out.

I'm testing a theme release in multiple versions of WordPress using xampplite on localhost on a PC.

I'm having a problem on WP 2.9.2 that does not occur on any other newer installations of WP.

Take a look at the query below. As long as I leave the commented line in place, it works fine. However, when I uncomment the line, it crashes my xampplite Apache server. WTF?

$the_query = new WP_Query(array(
  'posts_per_page' => 5,
  'offset' => 0, 
  'order' => 'ASC',
  'post__not_in' => get_option("sticky_posts"),
//  'cat' => get_cat_ID('top-menu'),
  ));
print "<p>header.php";exit;

I've even tried to hard code the cat attribute to a static number:

'cat' => 3

It still crashes!

Is this a problem with the code, wordpress 2.9.2 or with my Xamplite setup? Seems odd that it works in all newer other versions of WP I've got set up on this same box.

6

2 Answers 2

1

The only thing I see as even close to syntactically questionable is that showposts could be replaced with posts_per_page.

2
  • Thanks for the input editor. It works fine with either. The only problem it has is when the cat argument is present. I'm burning two days on tracking this down, argggh!
    – Scott B
    Feb 9, 2011 at 22:03
  • The former, but really I'm sort of reaching. It looks like WP will set $query['posts_per_page'] to $query['showposts'] in &get_posts() function, in both 2.9 and 3.0 (core.trac.wordpress.org/browser/tags/3.0.5/wp-includes/…). I think that's all the query vars listed in fill_query_vars().
    – editor
    Feb 9, 2011 at 22:08
0

Realise this old now, but this may help people finding this via Google:

I had problems with Apache dying when running similar code within a function called by the pre_get_posts hook. Problem was I missed the conditional:

$query->is_main_query()

meaning it was doing work for all the queries, not just the main one. Adding that fixed the problem for me. The full conditional I use is (then other code above below that:

if ( ! is_category() || ! $query->is_main_query() || ! is_a( $query, 'WP_Query' ) )
    return;
1
  • is_main_query() didn’t even exist in 2.9.2. That cannot be a valid answer.
    – fuxia
    Jun 30, 2012 at 13:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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