White screen of death on index.php page 3 and above?

Question

I am experimenting with custom loops and following the tutorial of the illustrious Chip Bennett, and I actually got everything to work on index.php!

Up to, that is, page 3.

Everything works lovely when I go to page 2. On any higher page, it’s white screen of death time.

To my eye, my code is practically identical to the one provided in the link, but for completeness:

    $hero_args = array(
    "posts_per_page" => "1",
    );

$hero_args['paged'] = get_query_var( 'paged' ) 
    ? get_query_var( 'paged' ) 
    : 1;

$heroPost = new WP_Query($hero_args);

<div class = "blog_content_wrap">
           <div class = "hero_blog">
               <?php    $temp_query = $wp_query;
               $wp_query   = NULL;
               $wp_query   = $heroPost;?>

               <?php if ($heroPost -> have_posts()): ?>
                Query contains something
              
                <?php while ($heroPost -> have_posts()):
                    $heroPost -> the_post();
                    the_title();?>
                   
                    
                <?php endwhile;
       
               ?>
                

               <?php else:?>
                No posts found, sucker
               <?php endif; 

               wp_reset_postdata();
               
            
               print_r ($hero_args['paged']);
               previous_posts_link( 'Older Posts' );
                next_posts_link( 'Newer Posts', $heroPost->max_num_pages );
               the_posts_pagination();
               $wp_query = NULL;
               $wp_query = $temp_query;
               ?>
    
           
            </div>

I have a sneaking suspicion it has to do with the max_num_pages? But I’m not sure at all. It’s a PHP error, but I have no idea how to ask the question more precisely. If someone has a good idea of where to look, I’d appreciate it.

TLDR localhost/blogname/ = fine
localhost/blogname/page/2 = fine
localhost/blogname/page/3 = total destruction

Working Fine
Total failure

0
Kaspar Hauser 4 months 0 Answers 18 views 0

Leave an answer