Support » Fixing WordPress » 404 error with pagination

  • I’ve searched for answers for this but found nothing conclusive.

    I have a custom theme that is heavily modded, admin section and main site with custom menus etc

    My problem is on my blog pages using pagination I get a 404 error when I go to page 2/3 etc

    I have turned off all plugins and commented out the entire functions.php page. still results in the same error, checked my htaccess

    # BEGIN WordPress
    <IfModule mod_rewrite.c>
    ErrorDocument 404 /index.php?error=404
    RewriteEngine On
    RewriteBase /
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]
    # END WordPress

    I use category for blogs so my blog is at /blog/ and news at /news/

    I reduced category.php to look like this

        $paged = (get_query_var('page')) ? get_query_var('page') : 1;
        $args = array(
    <?php query_posts('posts_per_page=2'); while (have_posts()) : the_post(); ?>
        <li><? the_title(); ?></li>
    <?php endwhile;
    wp_reset_postdata(); ?>
    <?php get_footer(); ?>

    I’m using wp_pagenavi and have tried a plugin that claims to fix the issue with pagination and category pages.

    no matter what I do I can’t fix this issue 🙁

    the site can be found at
    though the blog pages are not in the menu
    you can find blog pages using category.php by going to
    you will notice it changes the url to /blog/ rather than /category/blog/ I have no idea why this is happening, I don’t think it is something I have done (still does it when I turn off plugins and comment out the functions.php page) you can also try things like /t/ and it will load a page that begins with t – it’s crazy and I have no idea where it has come from 3.5 perhaps?

    any help is much appreciated if I had hair I would be pulling it out!.

Viewing 7 replies - 1 through 7 (of 7 total)
  • try adding this argument to your query :

    'paged' => $paged,

    I would do the whole query this way :

    $args = array(
      'posts_per_page' => '2',
       'paged' => $paged
    $myposts = new WP_Query($args);
    while ($myposts->have_posts()) : $myposts->the_post();
        get_template_part('content_post'); // or whatever you need to do here

    Normally you do not need this :

    $paged = (get_query_var('page')) ? get_query_var('page') : 1;

    ahh this is something I had in the past, tried it several ways in the array $args and in the query string query_posts('posts_per_page=2&paged=' . $paged);

    No luck I’m afraid, but thank you for a fast response, it’s appreciated.

    I have also found that on a static homepage you need to name this page and not paged, if that helps out anybody else with the same issue.

    Though this doesn’t answer my issue (I have tried page too just in case.)


    There is lots of different stuff going on here. Firstly you need to check your permalink structure settings about /category/blog/ going to /blog/

    Secondly to sort out the correct pagination try using the default blog settings go to Admin > Settings > Reading and change the blog posts show at most… setting

    And if you genuinely want to do a custom loop try

    I’m using the default permalink option of although I have tried others including the default none nice name setting.

    the blog page is not set I do however use a custom static front page.

    the post per page setting is set to 2 for purpose of testing.

    None of these settings when tried differently offer a solution.

    My next step is to write custom scripts to use the loop differently, though I would prefer to use the wp default options, unless I really have to – it’s looking like I have to but it’s truly head banging stuff trying to work out why it won’t just work. It has put me off using WordPress as the main development back-end for all the sites we create, have started to look at Joomla

    I’d advise you to try and add functionality one step at a time. Use the default theme to get your permalink structure setup in the way that you want and the right number of posts per page, then create a child theme where you can add in a custom loop. Finally you can integrate this into your own theme once you have got it all working.

    I magically fixed it for that one page /blog/ still does the same when clicking a tag but I can live without that feature and move development away from wordpress as it’s just too easy to break.

    Thanks everybody for your help

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘404 error with pagination’ is closed to new replies.