Custom Post Types 404 with Pagination due to Reading Settings
-
When using custom post types on my home page I receive 404’s on later paginated pages. (eg. pages 1-6 work perfectly, pages 7-11 give 404’s)
I know the cause of this issue has to do with the Reading Settings>Blog pages show at most option. If the “Blog pages show at most” is greater than my “posts_per_page” number in my query I receive 404’s.
The common solution to this seems to be setting the “Blog pages show at most” to 1, but I need the pagination to work properly without restricting the “Blog pages show at most” to 1 (for I am using infinite scroll, and the plugin stops retrieving posts when it hits a 404).
Here is how my query currently looks:
if ( get_query_var('paged') ) { $paged = get_query_var('paged'); } else if ( get_query_var('page') ) { $paged = get_query_var('page'); } else { $paged = 1; } $type = 'events'; $args=array( 'post_type' => $type, 'post_status' => 'publish', 'paged' => $paged, 'posts_per_page' => 10, ); $wp_query = null; $wp_query = new WP_Query(); $wp_query->query($args);
Any help would be much appreciated.
- The topic ‘Custom Post Types 404 with Pagination due to Reading Settings’ is closed to new replies.