0

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;?>

           &lt;?php if ($heroPost -&gt; have_posts()): ?&gt;
            Query contains something

            &lt;?php while ($heroPost -&gt; have_posts()):
                $heroPost -&gt; the_post();
                the_title();?&gt;


            &lt;?php endwhile;

           ?&gt;


           &lt;?php else:?&gt;
            No posts found, sucker
           &lt;?php endif; 

           wp_reset_postdata();


           print_r ($hero_args['paged']);
           previous_posts_link( 'Older Posts' );
            next_posts_link( 'Newer Posts', $heroPost-&gt;max_num_pages );
           the_posts_pagination();
           $wp_query = NULL;
           $wp_query = $temp_query;
           ?&gt;


        &lt;/div&gt;

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

Probably not necessary, but here's my full index.php:

<?php get_header(); ?>

<!--replace index.php with the list, home.php for the 'main' blog? --> <?php

$hero_args = array( "posts_per_page" => "1", /* 'meta_key' => 'meta-checkbox', 'meta_value' => 'yes' */

);

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

$post_args = array( "posts_per_page" => "3", "offset" => "1",

);

$pag_args1 = array( 'format' => '?page1=%#%', 'current' => $page1, 'total' => $query1->max_num_pages, 'add_args' => array( 'page2' => $page2 ) );

$heroPost = new WP_Query($hero_args);

// the loop ?>

<?php

/* if ( $heroPost->have_posts() ) { while ( $heroPost->have_posts() ) { $heroPost->the_post(); if ( (int) $heroPost->current_post === 0 ) { // loop content for hero post } } }*/

?>

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

           &lt;?php if ($heroPost -&gt; have_posts()): ?&gt;
            Query contains something

            &lt;?php while ($heroPost -&gt; have_posts()):
                $heroPost -&gt; the_post();
                the_title();?&gt;


            &lt;?php endwhile;

           ?&gt;


           &lt;?php else:?&gt;
            No posts found, sucker
           &lt;?php endif; 

           wp_reset_postdata();


           print_r ($hero_args['paged']);
           previous_posts_link( 'Older Posts' );
            next_posts_link( 'Newer Posts', $heroPost-&gt;max_num_pages );
           the_posts_pagination();
           $wp_query = NULL;
           $wp_query = $temp_query;
           ?&gt;


        &lt;/div&gt;


       &lt;div class = &quot;blog_grid&quot;&gt;





            &lt;/div&gt;




        &lt;div class = &quot;blog_div&quot;&gt;
          &lt;h1 class = &quot;read_more_title&quot;&gt;Blog Navigation&lt;/h1&gt;
          &lt;form&gt;

            &lt;input type=&quot;text&quot;&gt;&lt;/input&gt;
            &lt;button&gt;Search&lt;/button&gt;
            &lt;button&gt;By Category&lt;/button&gt;
            &lt;button&gt;By Date&lt;/button&gt;
            &lt;button&gt;List&lt;/button&gt;



        &lt;/div&gt;





       &lt;/div&gt;
      &lt;/div&gt;

      &lt;?php get_footer(); ?&gt;

      &lt;!--&lt;div class = &quot;blog_div&quot;&gt;
          &lt;h3&gt;tit&lt;/h3&gt;
          &lt;h4&gt;Olivia Bennett&lt;/h4&gt;
          &lt;p&gt; ex&lt;/p&gt;
             &lt;a href=&quot;#&quot;&gt;Read more&lt;/a&gt;
        &lt;/div&gt;
        &lt;div class = &quot;blog_div&quot;&gt;
          &lt;h3&gt;My Day at the Spinster's House&lt;/h3&gt;
          &lt;h4&gt;Olivia Bennett&lt;/h4&gt;
          &lt;p&gt;Lorem ipsum dolor, sit amet consectetur adipisicing elit. Doloremque ad quae saepe dolorum. 
            Sequi quidem doloremque, explicabo, necessitatibus eum dicta perferendis
             totam ex dolor at eos quae aliquid iusto fugiat?&lt;/p&gt;
             &lt;a href=&quot;#&quot;&gt;Read more&lt;/a&gt;
        &lt;/div&gt;
        &lt;div class = &quot;blog_div&quot;&gt;
          &lt;h3&gt;My Day at the Spinster's House&lt;/h3&gt;
          &lt;h4&gt;Olivia Bennett&lt;/h4&gt;
          &lt;p&gt;Lorem ipsum dolor, sit amet consectetur adipisicing elit. Doloremque ad quae saepe dolorum. 
            Sequi quidem doloremque, explicabo, necessitatibus eum dicta perferendis
             totam ex dolor at eos quae aliquid iusto fugiat?&lt;/p&gt;
             &lt;a href=&quot;#&quot;&gt;Read more&lt;/a&gt;
        &lt;/div&gt;--&gt;

0 Answers0