Custom Post Type Query_Posts Pagination 404 Error
-
Hi
I created a custom post type ‘portfolio’ and created a page called portfolio in the page I want to display all posts for this post type so I added 2 queries, one is for showing all custom taxonomy entries for ‘skills’ linked to the post type the other displays the posts.
<div id="content-portfolio"> <div class="filterSkills"> <?php //List all the terms in a skills taxonomy, without a link $terms = get_terms("Skills"); $count = count($terms); if ( $count > 0 ){ echo 'Showing all Portfolio Items in the following skill sets:'; foreach ( $terms as $term ) { echo ' <a href="' .get_bloginfo('url'). '/skills/' . $term->slug . '/" class="' . $term->slug . '" title="List all ' . $term->name . ' items">' . $term->name . '</a>'; } } ?> </div> <?php $limit = get_option('posts_per_page'); $paged = (get_query_var('paged')) ? get_query_var('paged') : 1; query_posts('showposts=' . $limit . '&paged=' . $paged .'&post_type=portfolio'); $wp_query->is_archive = true; $wp_query->is_home = false; ?> <?php if (have_posts()) : while (have_posts()) : the_post(); ?> <!-- POST START --><br/> <div class="post"> <!-- ENTRY START --> <div class="date"> <p>Posted on <span style="font-weight: bold;"><?php the_time( 'D d M Y ' ); ?></span> (about <?php echo human_time_diff( get_the_time('U'), current_time('timestamp') ) . ' ago'; ?>) by <span style="font-weight: bold;"><?php the_author_link(); ?></span></p> </div> <div class="entry"> <h2 class="title"><a href="<?php the_permalink(); ?>" rel="bookmark" title="<?php the_title(); ?>"><?php the_title(); ?></a></h2> </div> <!-- ENTRY END --> </div> <!-- POST END --> <?php endwhile; ?> <!-- Page Navigation --> <?php if (function_exists('wp_pagenavi')) : ?> <div class="pagenavi"> <?php wp_pagenavi(); ?> </div> <?php else : // Use WordPress default page navigation. ?> <div class="pages"> <span class="older"><?php next_posts_link('« Older Entries'); ?></span> <span class="newer"><?php previous_posts_link('Newer Entries »'); ?></span> </div> <?php endif; ?> <?php else : ?> <p>Sorry, but nothing matched your search criteria.</p> <?php get_search_form(); ?> <?php endif; ?> </div>
The post is displayed as well as the ‘older entries’ pagination link, however when the pagination link is clicked a 404 error occurs.
I used print_r($wp_query); to display the queries on both pages, 404 & portfolio, this is what was returned:
Portfolio:
WP_Query Object ( [query_vars] => Array ( [showposts] => 1 [paged] => 1 [post_type] => portfolio [error] => [m] => 0 [p] => 0 [post_parent] => [subpost] => [subpost_id] => [attachment] => [attachment_id] => 0 [name] => [static] => [pagename] => [page_id] => 0 [second] => [minute] => [hour] => [day] => 0 [monthnum] => 0 [year] => 0 [w] => 0 [category_name] => [tag] => [cat] => [tag_id] => [author_name] => [feed] => [tb] => [comments_popup] => [meta_key] => [meta_value] => [preview] => [s] => [sentence] => [fields] => [category__in] => Array ( ) [category__not_in] => Array ( ) [category__and] => Array ( ) [post__in] => Array ( ) [post__not_in] => Array ( ) [tag__in] => Array ( ) [tag__not_in] => Array ( ) [tag__and] => Array ( ) [tag_slug__in] => Array ( ) [tag_slug__and] => Array ( ) [ignore_sticky_posts] => [suppress_filters] => [cache_results] => 1 [update_post_term_cache] => 1 [update_post_meta_cache] => 1 [posts_per_page] => 1 [nopaging] => [comments_per_page] => 0 [no_found_rows] => [order] => DESC ) [tax_query] => WP_Tax_Query Object ( [queries] => Array ( ) [relation] => AND ) [meta_query] => WP_Meta_Query Object ( [queries] => Array ( ) [relation] => ) [post_count] => 1 [current_post] => -1 [in_the_loop] => [comment_count] => 0 [current_comment] => -1 [found_posts] => 2 [max_num_pages] => 2 [max_num_comment_pages] => 0 [is_single] => [is_preview] => [is_page] => [is_archive] => 1 [is_date] => [is_year] => [is_month] => [is_day] => [is_time] => [is_author] => [is_category] => [is_tag] => [is_tax] => [is_search] => [is_feed] => [is_comment_feed] => [is_trackback] => [is_home] => [is_404] => [is_comments_popup] => [is_paged] => [is_admin] => [is_attachment] => [is_singular] => [is_robots] => [is_posts_page] => [is_post_type_archive] => [query_vars_hash] => 2742cf66e85801295f90d192b9c874db [query_vars_changed] => [thumbnails_cached] => [query] => Array ( [showposts] => 1 [paged] => 1 [post_type] => portfolio ) [request] => SELECT SQL_CALC_FOUND_ROWS wp_posts.ID FROM wp_posts WHERE 1=1 AND wp_posts.post_type = 'portfolio' AND (wp_posts.post_status = 'publish') ORDER BY wp_posts.post_date DESC LIMIT 0, 1 [posts] => Array ( [0] => stdClass Object ( [ID] => 37 [post_author] => 1 [post_date] => 2012-08-21 19:33:08 [post_date_gmt] => 2012-08-21 17:33:08 [post_content] => hello hello [post_title] => test hello [post_excerpt] => [post_status] => publish [comment_status] => closed [ping_status] => closed [post_password] => [post_name] => test-hello [to_ping] => [pinged] => [post_modified] => 2012-08-25 08:17:41 [post_modified_gmt] => 2012-08-25 06:17:41 [post_content_filtered] => [post_parent] => 0 [guid] => https://localhost:23000/?post_type=portfolio&p=37 [menu_order] => 0 [post_type] => portfolio [post_mime_type] => [comment_count] => 0 [filter] => raw ) ) [post] => stdClass Object ( [ID] => 37 [post_author] => 1 [post_date] => 2012-08-21 19:33:08 [post_date_gmt] => 2012-08-21 17:33:08 [post_content] => hello hello [post_title] => test hello [post_excerpt] => [post_status] => publish [comment_status] => closed [ping_status] => closed [post_password] => [post_name] => test-hello [to_ping] => [pinged] => [post_modified] => 2012-08-25 08:17:41 [post_modified_gmt] => 2012-08-25 06:17:41 [post_content_filtered] => [post_parent] => 0 [guid] => https://localhost:23000/?post_type=portfolio&p=37 [menu_order] => 0 [post_type] => portfolio [post_mime_type] => [comment_count] => 0 [filter] => raw ) )
404:
WP_Query Object ( [query_vars] => Array ( [page] => 2 [portfolio] => page [post_type] => portfolio [name] => page [error] => [m] => 0 [p] => 0 [post_parent] => [subpost] => [subpost_id] => [attachment] => [attachment_id] => 0 [static] => [pagename] => [page_id] => 0 [second] => [minute] => [hour] => [day] => 0 [monthnum] => 0 [year] => 0 [w] => 0 [category_name] => [tag] => [cat] => [tag_id] => [author_name] => [feed] => [tb] => [paged] => 0 [comments_popup] => [meta_key] => [meta_value] => [preview] => [s] => [sentence] => [fields] => [category__in] => Array ( ) [category__not_in] => Array ( ) [category__and] => Array ( ) [post__in] => Array ( ) [post__not_in] => Array ( ) [tag__in] => Array ( ) [tag__not_in] => Array ( ) [tag__and] => Array ( ) [tag_slug__in] => Array ( ) [tag_slug__and] => Array ( ) [ignore_sticky_posts] => [suppress_filters] => [cache_results] => 1 [update_post_term_cache] => 1 [update_post_meta_cache] => 1 [posts_per_page] => 1 [nopaging] => [comments_per_page] => 0 [no_found_rows] => [order] => DESC ) [tax_query] => [meta_query] => WP_Meta_Query Object ( [queries] => Array ( ) [relation] => ) [post_count] => 0 [current_post] => -1 [in_the_loop] => [comment_count] => 0 [current_comment] => -1 [found_posts] => 0 [max_num_pages] => 0 [max_num_comment_pages] => 0 [is_single] => [is_preview] => [is_page] => [is_archive] => [is_date] => [is_year] => [is_month] => [is_day] => [is_time] => [is_author] => [is_category] => [is_tag] => [is_tax] => [is_search] => [is_feed] => [is_comment_feed] => [is_trackback] => [is_home] => [is_404] => 1 [is_comments_popup] => [is_paged] => [is_admin] => [is_attachment] => [is_singular] => [is_robots] => [is_posts_page] => [is_post_type_archive] => [query_vars_hash] => 94bef5fa2659ec263e682cd102950f11 [query_vars_changed] => [thumbnails_cached] => [query] => Array ( [page] => /2 [portfolio] => page [post_type] => portfolio [name] => page ) [request] => SELECT wp_posts.* FROM wp_posts WHERE 1=1 AND wp_posts.post_name = 'page' AND wp_posts.post_type = 'portfolio' ORDER BY wp_posts.post_date DESC [posts] => Array ( ) [queried_object] => [queried_object_id] => 0 )
Please someone help?
I have tried to find a possible solution on the web however none has worked so far?
Thanks!
- The topic ‘Custom Post Type Query_Posts Pagination 404 Error’ is closed to new replies.