Pagination for custom post type in WordPress not working?

code for pagination in custom type posts

<?php  $paged = ( get_query_var('paged') ) ? get_query_var('paged') : 1; // For pagination

$loop = new WP_Query( array('post_type' => 'Portfolio','posts_per_page' => 3,'orderby'=> 'menu_order',
'paged'=>$paged ) ); ?> //For implementing pagination
<?php if ($loop->have_posts()): ?>
<?php while ($loop->have_posts()) : $loop->the_post(); ?> <div id="latestproimg">
<a href="<?php the_permalink(); ?>" rel="bookmark">
<?php the_post_thumbnail('large', array('title' => false)); ?></a>
</div>
<div id="latestpostser">
<h2 class="entry-title"><a href="<?php the_permalink(); ?>" rel="bookmark">
<?php echo get_the_title(); ?></a></h2> //displaying the title
<?php //echo get_the_excerpt(); ?>
<?php //the_content( 'Read the full post »' ); ?> // for displaying the content
</div>
<div class="clr"></div>
<?php endwhile;
endif; ?>

Please tell me where is the mistake in code

Related posts

Leave a Reply

2 comments

  1. I also encountered this weird pagination problem even though I already put the $page option but heres what solved my problem try to change the paged parameter into page of your get_query_var function

    $paged = ( get_query_var('page') ) ? get_query_var('page') : 1; // For pagination
    

    let me know if it works

  2. get_query_var('paged') doesn’t work if the permalinks setting changes the url to something like http://domain.com/page/2/.... So, a more flexible version of @IoQ’s answer would be,

    $search_values['paged'] = (get_query_var('paged')) ? get_query_var('paged')
    : ((get_query_var('page')) ? get_query_var('page') : 1);
    

    This works if either permalinks is set to something like postname OR paged=xx is part of the url