문제

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.

도움이 되었습니까?

해결책

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

다른 팁

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;
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 wordpress.stackexchange
scroll top