danielwiener
Member
Posted 1 year 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:
http://wpquestions.com/question/show/id/701
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]
i have the exact same problem.
any ideas anyone?
danielwiener
Member
Posted 1 year 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.
www.designpositive.cz
Member
Posted 1 year ago #
Thanks a lot, you saved my day :)
brianmcculloh
Member
Posted 1 year ago #
Mine as well - thanks for posting your solution!
cornhustlah
Member
Posted 1 year 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:
http://wordpress.org/support/topic/custom-taxonomy-navigation-problem-paged1-works-paged2-doesnt
cornhustlah
Member
Posted 1 year 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:
http://wordpress.stackexchange.com/questions/16353/custom-taxonomy-not-working-with-posts-per-page-in-new-wp-query-pagination-probl
cornhustlah
Member
Posted 1 year 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($taxquery->max_num_pages>1){
if ($paged > 1) { ?>
<a href="<?php echo '?page=' . ($paged -1); //prev link ?>"><</a>
<?php
}
for($i=1;$i<=$taxquery->max_num_pages;$i++){?>
<a href="<?php echo '?page=' . $i; ?>" <?php echo ($paged==$i)? 'class="selected"':'';?>><?php echo $i;?></a>
<?php
}
if($paged < $taxquery->max_num_pages){?>
<a href="<?php echo '?page=' . ($paged + 1); //next link ?>">></a>
<?php
}
}?>
which i based off this semi-related support topic:
http://wordpress.org/support/topic/adding-pagination-to-a-wp_query-loop?replies=16
:D