How add pagination for custom post type?

Hello Everyone

If you are trying to add pagination on for your custom post type using “WP-PageNavi” plugin in your site then you have need to add custom post type query in wp_pagenavi() function after end of while loop

    $paged = get_query_var('paged') ? get_query_var('paged') : 1;

    $loop = new WP_Query( array( 'post_type' => 'portfolio-type', 'post_status' => 'publish', 'posts_per_page' =>'5','paged'=>$paged ) ); 

    while ( $loop->have_posts() ) : $loop->the_post(); 


<article id="post-<?php echo $postIDD; ?>" <?php post_class(); ?>>
    <h6><?php the_title();?></h6>

    <strong>About :</strong> 
    $post_7 = get_post($postIDD); 
    $cont = $post_7->post_content;
    echo strip_tags($cont); ?>
    <br><a target="_blank" href="<?php echo get_post_meta($postIDD,'wpcf-url',true); ?>">&nbsp;</a>    
endwhile; // end of the loop. 
wp_pagenavi( array( 'query' => $loop ) ); //pagination

Enjoy Code:!


Sr. Software Engineer

Tagged with: , , ,
Posted in Wordpress
4 comments on “How add pagination for custom post type?
  1. I’m amazed, I must say. Rarely do I come across a blog that’s both educative and interesting, and without a doubt, you’ve hit the nail on the head. The issue is something which too few men and women are speaking intelligently about. I am very happy that I found this in my search for something relating to this.

  2. What’s up it’s me, I am also visiting this web page daily,
    this website is actually fastidious and
    the users are really sharing nice thoughts.

  3. Alyce says:

    WOW just what I was looking for. Came here by searching for sfds

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

Recent Posts
%d bloggers like this: