Custom query_posts on cat page, page 2 is 404
-
I’m having a hard time figuring out pagination on my category page, when I’m using a custom query. Basically, I have some code to figure out what category is being called, then it writes a new query string with other categories and does a query_post for that string. I have also added the $paged parameter:
<?php if ( $query_string === 'category_name=home' ) { $query_string = 'cat=11,14,15'; $cat_title = 'Your Home'; } else if ( $query_string === 'category_name=car' ) { $query_string ='cat=10,12,13'; $cat_title = 'Your Car'; } else if ( $query_string === 'category_name=property' ) { $query_string ='cat=22,23,24'; $cat_title = 'Your Property'; } else if ( $query_string === 'category_name=personal' ) { $query_string ='cat=19,20,21'; $cat_title = 'Personal'; } else if ( $query_string === 'category_name=travel' ) { $query_string ='cat=16,17,18'; $cat_title = 'Travel'; } $paged = (get_query_var('paged')) ? get_query_var('paged') : 1; query_posts ($query_string . '&paged=' . $paged); if ( empty ($cat_title) ) { $cat_title = single_cat_title( '', false ); } ?>
I also have permalinks set up to be /%category%/%postname%/ and I’m running the WP No Category Base plugin to remove /category/ from the URL.
The normal category page pagination works OK, but when these custom category pages are retrieved the first page works fine but the second page (/home/page/2/) is 404. I’m not sure why but it’s either due to the permalinks changes or wrong pagination code (or both).
Any insight would be appreciated! Thanks!
- The topic ‘Custom query_posts on cat page, page 2 is 404’ is closed to new replies.