Pagination on custom post type (404 not found)
-
Hi, I have a problem with custom post type. I used Custom Post Type UI plugin.
My code in archive.php:<?php $type = 'products'; if ( get_query_var('paged') ) { $paged = get_query_var('paged'); } else if ( get_query_var('page') ) { $paged = get_query_var('page'); } else { $paged = 1; } $args=array( 'post_type' => $type, 'cat' => $cat, 'post_status' => 'publish', 'paged' => $paged, 'posts_per_page' => 3, 'caller_get_posts'=> 3 ); $temp = $wp_query; // assign original query to temp variable for later use $wp_query = null; $wp_query = new WP_Query(); $wp_query->query($args); ?> <?php while($wp_query->have_posts()) : $wp_query->the_post(); ?>
I’m using wp-pagenavi plugin for pagination.
<?php wp_pagenavi(); $wp_query = null; $wp_query = $temp; ?>
…and code from plugin:
register_post_type('products', array( 'label' => 'Produkty','description' => '','public' => true,'show_ui' => true,'show_in_menu' => true,'capability_type' => 'post','hierarchical' => false,'rewrite' => array('slug' => ''),'query_var' => true,'has_archive' => true,'exclude_from_search' => false,'supports' => array('title','editor','excerpt','trackbacks','custom-fields','comments','revisions','thumbnail','author','page-attributes',),'taxonomies' => array('category',),'labels' => array ( 'name' => 'Produkty', 'singular_name' => 'Produkt', 'menu_name' => 'Produkty', 'add_new' => 'Add Produkt', 'add_new_item' => 'Add New Produkt', 'edit' => 'Edit', 'edit_item' => 'Edit Produkt', 'new_item' => 'New Produkt', 'view' => 'View Produkt', 'view_item' => 'View Produkt', 'search_items' => 'Search Produkty', 'not_found' => 'No Produkty Found', 'not_found_in_trash' => 'No Produkty Found in Trash', 'parent' => 'Parent Produkt', ),) );
link /category/produkty/page/2/ return 404 page
and ?cat=4&paged=2 tooPlease help me.
Cheers.
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
- The topic ‘Pagination on custom post type (404 not found)’ is closed to new replies.