Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

So I have a search function that just fetch custom posts and return them as a list.

function search() {

   // post query args
    $args = array(
        'post_type' => 'post_type',
        'posts_per_page' => -1,
        'post_status' => 'publish'
    );

    // markup
    $markup = '<ul>';

    //the loop
    $loop = new WP_Query($args);
    while ($loop->have_posts()) {
        $loop->the_post();
        $markup .= '<li></li>';
    } wp_reset_postdata();

    $markup .='</ul>';

    echo $markup;
}

This works with under a hundred posts but with over a thousand posts, it doesn't. It just throws an error. If I switch to get_posts(), the same thing happens. Is there another way I could this?

share|improve this question
    
Is the error a timeout error? –  kaiser Oct 3 '12 at 2:07
    
@kaiser: That's another problem actually because our admin has not enabled error reporting in our server. Could you tell me if this should work and that the issue is on the server config or something? Because I can confirm that my function perfectly works on smaller number of posts. –  jilseego Oct 3 '12 at 2:10
1  
if it's not timing out, you're likely running out of memory –  Milo Oct 3 '12 at 2:56
    
No error reporting? Stop working. Senseless task. –  kaiser Oct 3 '12 at 10:20
    
@milo as an answer please –  Rarst Oct 14 '12 at 21:00
add comment

1 Answer

up vote 1 down vote accepted

If it's not timing out, you're likely running out of memory.

share|improve this answer
add comment

Your Answer

 
discard

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.