Pagination for custom post
-
Hi all, I have trouble for register custom post and pagination. My custom post type is “ebook” with vode below
register_post_type($this->type,array( 'label'=>'Ebook Store', 'labels'=>array( // n/ a ), 'public'=>true, 'hierarchical'=>false, 'rewrite'=>array('slug'=>$this->type,'with_front'=>false), 'query_var'=>true, 'supports'=>array('title','editor','thumbnail','author'), ));and i write a simple code for pagination like:
<?php global $paged; $page = $paged==0 ? 1:0; $args =array( 'post_type'=>'eboookstore', 'paged'=>$page, 'showposts'=>1, ); $loop = new WP_Query($args); if($loop->have_posts()): while($loop->have_posts()): $loop->the_post(); ?> <?php the_post_thumbnail('ebook-store'); ?> <br/> <a href="<?php the_permalink();?>"><?php the_title(); ?></a> <br> <?php endwhile;endif; ?> <?php $posts_per_page = get_option('posts_per_page'); $all_book = wp_count_posts('eboookstore'); $pages = ceil($all_book->publish / $posts_per_page); for($i = 1;$i<=$pages;$i++){ echo '<a href="'.get_pagenum_link($i).'">'.$i.'</a>'; } ?>And my trouble is:
– If i don’t create 404.php page in my template, every thing work successful.
– If i create 404.php, i will get “404 page not found” page.if page url :
http://localhost/wp/?paged=4 –> 404 page
and add to “post_type” to page url:
http://localhost/wp/?paged=4&post_type=ebookstore –> work successPM: I have read many topics like my case, but not solve this problem.
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
The topic ‘Pagination for custom post’ is closed to new replies.