Monday, 26 August 2013

Custom post and category template pagination problem

Custom post and category template pagination problem References I have a category template which holds a query to custom post with a category. The strange thing is when the pagination loads it displays how many pages we have. But when I click on the second page of the pagination it gives me a 404 page. If I make the query only to fetch the custom post or to fetch the category it works fine. After I have refresh the query with the test for the custom post and the category it works fine. Here is the code of the category template:
6, \'post_type\' => \'awards-pub\', \'cat\'=>6, \'paged\' => $paged, \'order\'=>\'DESC\' ); $wp_query = new WP_Query( $args ); //wp_query->query(\'showposts=5\'.\'&paged=\'.$paged); $i=1; while ( $wp_query->have_posts() ) { $wp_query->the_post(); ?>
And this is the pagination: global $wp_query; $big = 999999999; echo paginate_links(array( \'base\' => str_replace($big, \'%#%\', get_pagenum_link($big)), \'format\' => \'?paged=%#%\', \'current\' => max(1, get_query_var(\'paged\')), \'total\' => $wp_query->max_num_pages, \'prev_next\' => True, \'prev_text\' => __(\'«\'), \'next_text\' => __(\'»\'), )); And this is the custom post: register_post_type(\'awards-pub\', // Register Custom Post Type array( \'labels\' => array( \'name\' => __(\'Awards\', \'awardspub\'), // Rename these to suit \'singular_name\' => __(\'Awards Post\', \'awardspub\'), \'add_new\' => __(\'Add Awards\', \'awardspub\'), \'add_new_item\' => __(\'Add Awards Post\', \'awardspub\'), \'edit\' => __(\'Edit\', \'awardspub\'), \'edit_item\' => __(\'Edit Awards Post\', \'awardspub\'), \'new_item\' => __(\'New Awards Post\', \'awardspub\'), \'view\' => __(\'View Awards Post\', \'awardspub\'), \'view_item\' => __(\'View Awards Post\', \'awardspub\'), \'search_items\' => __(\'Search Awards Post\', \'awardspub\'), \'not_found\' => __(\'No Awards Posts found\', \'awardspub\'), \'not_found_in_trash\' => __(\'No Awards Posts found in Trash\', \'awardspub\') ), \'public\' => true, \'hierarchical\' => true, // Allows your posts to behave like Hierarchy Pages \'has_archive\' => true, \'supports\' => array( \'title\', \'editor\', \'excerpt\', \'comments\', \'thumbnail\' ), // Go to Dashboard Custom HTML5 Blank post for supports \'can_export\' => true, // Allows export in Tools > Export \'taxonomies\' => array( \'post_tag\', \'category\' ) // Add Category and Post Tags support )); And to add the category to the custom post: register_taxonomy_for_object_type(\'category\', \'awards-pub\'); register_taxonomy_for_object_type(\'post_tag\', \'awards-pub\');

No comments:

Post a Comment