Ready to get started?Download WordPress


[resolved] [closed] Custom Taxonomies with Pagination getting 404, Page Not Found (9 posts)

  1. danielwiener
    Posted 4 years ago #

    For several custom taxonomies I am using taxonomy.php to show a list of posts. It works fine without pagination. And I can show the first page of the pagination but page 2 gets at 404, page not found.
    In other words http://www.haringkids.com/lesson_plans/?curriculum=art works but http://www.haringkids.com/lesson_plans/?curriculum=art&paged=2 goes to "page not found". (If you go to these pages, you will see some var_dumps, just ignore them.)

    Some of the code related to paging comes from:

    It seems to me the problem is not exactly with the pagination but once "paged=2" is added to the url, WP is not using taxonomy.php

    Anyway. I am stymied. Any help would be much appreciated.

    Here is my code:

    [Code moderated as per the Forum Rules. Please use the pastebin]

  2. Anastis Sourgoutsidis
    Posted 4 years ago #

    i have the exact same problem.

    any ideas anyone?

  3. danielwiener
    Posted 4 years ago #

    It turns out that I needed to set posts per page to 12 on the Settings -> Reading page in WP admin. I probably did not need the custom query, in that case either. Hope this helps someone.

  4. www.designpositive.cz
    Posted 3 years ago #

    Thanks a lot, you saved my day :)

  5. brianmcculloh
    Posted 3 years ago #

    Mine as well - thanks for posting your solution!

  6. cornhustlah
    Posted 3 years ago #

    i came across this problem before and also came up with the same solution and i assumed the problem was related to my inexperience with custom taxonomies, however even then i knew somethin was amiss, because im certain i've not had issues with pagination using custom queries of custom post types without custom taxonomies (lol, say that 3x fast :P) ... now that i'm again trying to get pagination to work in a Custom Post Type & Custom Taxonomy scenario WITHOUT editing the Reading settings (because i want to use Infinite Scroll JS with one post-per-page in my query), im running into the same exact problem.

    ive also found a related post where the OP seems to have solved the problem, but i dont quite get the solution:

  7. cornhustlah
    Posted 3 years ago #

    OK :::

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

    should actually be:

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

    see here:

  8. cornhustlah
    Posted 3 years ago #

    i should also mention that next_posts_link(), previous_posts_link() and posts_nav_link() all pull up a faulty URL and i had to catch this custom setup for pagination:

    <?php // OK, custom tax's dont work nice with query_posts (i think) but they DEF dont work nice with next_posts(), previous_posts() and  posts_nav_link()
                  // SO, got the custom page nav from here:
                  // http://wordpress.org/support/topic/adding-pagination-to-a-wp_query-loop?replies=16
              if ($paged > 1) { ?>
                <a href="<?php echo '?page=' . ($paged -1); //prev link ?>"><</a>
                <a href="<?php echo '?page=' . $i; ?>" <?php echo ($paged==$i)? 'class="selected"':'';?>><?php echo $i;?></a>
              if($paged < $taxquery->max_num_pages){?>
                <a href="<?php echo '?page=' . ($paged + 1); //next link ?>">></a>

    which i based off this semi-related support topic:


  9. esmi
    Forum Moderator
    Posted 3 years ago #

Topic Closed

This topic has been closed to new replies.

About this Topic