Skip to main content
Better formatting
Source Link
Pieter Goosen
  • 55.4k
  • 23
  • 115
  • 209

Pagination 404s on regular posts. Multiple solutions tried. Please read before marking as duplicatecustom query

I know this topic has been discussed to death, but I have gone through dozens and dozens of posts and tried dozens of dozens of fixes and have made no headway with my issue. Please read before downvoting or marking as duplicate.

The basic issue is that every paginated page for my blog is going to a 404 page. /page/2/, /page/3/, etc. It used to be working fine, but is not now. I think maybe the change to 3.9 did it.

home.php <?php require dirname( __FILE__ ) . '/blog-page.php';

    <?php require dirname( __FILE__ ) . '/blog-page.php';

blog-page.php http://pastebin.com/VDuBMgjf

<?php
/*
Template Name: Blog Page - Custom
*/
 
get_header(); ?>

<---CUSTOM CODE--->

<?php
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
   $args = array(
       'posts_per_page' => 5,
       'post_type' => 'post',
       'paged' => $paged
   );

$wp_query = new WP_Query($args);

if($wp_query->have_posts()) : 

   while($wp_query->have_posts()) : $wp_query->the_post(); ?>

<---CUSTOM CODE--->
                                                                                               
 
   endwhile;
                                                                                        
wp_reset_postdata();?>

<div class="nav-previous alignleft"><?php next_posts_link( 'Older posts' ); ?></div>
<div class="nav-next alignright"><?php previous_posts_link( 'Newer posts' ); ?></div>
<?php  endif; wp_reset_query();

If it helps, here is a test sitetest site I've set up with the page in question. I've left it off with the default wordpress pagination. http://hracuity.staging.wpengine.com/blog/

I've run out of things to try. Any helpsuggestions would be appreciated.

Pagination 404s on regular posts. Multiple solutions tried. Please read before marking as duplicate

I know this topic has been discussed to death, but I have gone through dozens and dozens of posts and tried dozens of dozens of fixes and have made no headway with my issue. Please read before downvoting or marking as duplicate.

The basic issue is that every paginated page for my blog is going to a 404 page. /page/2/, /page/3/, etc. It used to be working fine, but is not now. I think maybe the change to 3.9 did it.

home.php <?php require dirname( __FILE__ ) . '/blog-page.php';

blog-page.php http://pastebin.com/VDuBMgjf

If it helps, here is a test site I've set up with the page in question. I've left it off with the default wordpress pagination. http://hracuity.staging.wpengine.com/blog/

I've run out of things to try. Any help would be appreciated.

Pagination 404s on custom query

The basic issue is that every paginated page for my blog is going to a 404 page. /page/2/, /page/3/, etc. It used to be working fine, but is not now. I think maybe the change to 3.9 did it.

home.php

    <?php require dirname( __FILE__ ) . '/blog-page.php';

blog-page.php

<?php
/*
Template Name: Blog Page - Custom
*/
 
get_header(); ?>

<---CUSTOM CODE--->

<?php
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
   $args = array(
       'posts_per_page' => 5,
       'post_type' => 'post',
       'paged' => $paged
   );

$wp_query = new WP_Query($args);

if($wp_query->have_posts()) : 

   while($wp_query->have_posts()) : $wp_query->the_post(); ?>

<---CUSTOM CODE--->
                                                                                               
 
   endwhile;
                                                                                        
wp_reset_postdata();?>

<div class="nav-previous alignleft"><?php next_posts_link( 'Older posts' ); ?></div>
<div class="nav-next alignright"><?php previous_posts_link( 'Newer posts' ); ?></div>
<?php  endif; wp_reset_query();

If it helps, here is a test site I've set up with the page in question. I've left it off with the default wordpress pagination.

I've run out of things to try. Any suggestions would be appreciated.

Source Link
jphogan
  • 5
  • 1
  • 1
  • 3

Pagination 404s on regular posts. Multiple solutions tried. Please read before marking as duplicate

I know this topic has been discussed to death, but I have gone through dozens and dozens of posts and tried dozens of dozens of fixes and have made no headway with my issue. Please read before downvoting or marking as duplicate.

The basic issue is that every paginated page for my blog is going to a 404 page. /page/2/, /page/3/, etc. It used to be working fine, but is not now. I think maybe the change to 3.9 did it.

Here are some of the many things I have tried in an effort to fix this. The end result of all of these were the same. The paginated links 404'd.

  • deactivated all plugins
  • removed and reset permalinks multiple times
  • tried permalinks as default rather than /postname
  • Ensured my Reading Settings > Blog pages show at most was set to the same number as my loop. (as well as more and less to test)
  • I tried two separate navigation plugins and the default wordpress pagination (older posts) and it 404s every time. tried using parse_query
  • tried paginate_links

Here is my code (or links to my code):

home.php <?php require dirname( __FILE__ ) . '/blog-page.php';

blog-page.php http://pastebin.com/VDuBMgjf

If it helps, here is a test site I've set up with the page in question. I've left it off with the default wordpress pagination. http://hracuity.staging.wpengine.com/blog/

I've run out of things to try. Any help would be appreciated.