Pagination with Custom Post Type is Broken
-
Hi,
I have 3 post type ; “post”, “dersler”, “ipuclari”. I want to show all of them in the index page. I try this with this code :
<?php $pagedd = (get_query_var('paged')) ? get_query_var('paged') : 1; $wp_query = new WP_Query(array('paged'=>$pagedd, 'post_type'=>array('post','dersler','ipuclari'))); if(have_posts()): while(have_posts()): the_post(); ?>
And my pagination code is :
function pagination(){ global $paged,$wp_query; if(empty($paged)) $paged = 1; $pages = $wp_query->max_num_pages; $is_start = (1 == $paged) ? true : false; $is_end = ($pages == $paged) ? true : false; $for_start = ($paged-2 < 1) ? 1 : $paged-2; $for_end = ($paged+2 > $pages) ? $pages : $paged+2; echo '<ul class="pageNumbers">'; echo ($is_start) ? "" : "<li><a href='".get_pagenum_link(1)."'>? ?lk Sayfa</a></li>"; echo ($paged > 1) ? "<li><a href='".get_pagenum_link($paged-1)."'>?</a></li>" : ""; for($i=$for_start; $i<=$for_end; $i++){ echo ($paged == $i) ? "<li class='active'><a href='javascript:void;'>$i</a></li>" : "<li><a href='".get_pagenum_link($i)."'>$i</a></li>"; } echo ($paged < $pages) ? "<li><a href='".get_pagenum_link($paged+1)."'>?</a></li>" : ""; echo ($is_end) ? "" : "<li><a href='".get_pagenum_link($pages)."'>Son Sayfa ?</a></li>"; echo '</ul>'; echo "<span class='pageInfo'>$pages sayfada $paged. sayfadas?n?z</span>"; }
Pagination is work greatly. But if i click 5 site goes mysite.com/page/5/ but wordpress redirect 404 error page.
Note: if i write paged manually like ;
$wp_query = new WP_Query(array('paged'=>5, 'post_type'=>array('post','dersler','ipuclari')));
this perfectly show page 5. but mysite.com/page/5 doesn’t work please somebody help me :/
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
- The topic ‘Pagination with Custom Post Type is Broken’ is closed to new replies.