Title: Custom Posts &amp; Pagination?
Last modified: August 20, 2016

---

# Custom Posts & Pagination?

 *  [visumdesign](https://wordpress.org/support/users/visumdesign/)
 * (@visumdesign)
 * [13 years, 5 months ago](https://wordpress.org/support/topic/custom-posts-pagination-1/)
 * I know this has been asked a million times, I spent all day yesterday researching
   how to implement pagination.
 *  I finally understand it for the most part, when it comes down to the custom 
   post type I am running into confusion, I hope someone can clarify it for me.
 * The reason I am creating a new topic is because I want to find a solution based
   on the code I have.
 * Here is some snippets of the code inside my 2 column portfolio template, yes 
   this is pagination for portfolio type posts.
 *     ```
       <?php $loop = new WP_Query(array(
                 'post_type' => 'project',
                 'posts_per_page' => 2));
   
              $count =0;
       ?>
       ```
   
 * So this is a variable that controls how many posts to display, for testing I 
   set it to 2. As for pagination I am using kriesi_pagination and that code is 
   in my functions.php and is called inside the template
 * `<?php kriesi_pagination($loop->max_num_pages, $range = 2); ?>`
 * I added the $loop variable and pagination appears on the page, but as the issue
   I was having yesterday page 2 shows the same posts, so the solution was to add
 *     ```
       <?php
       if ( get_query_var('paged') ) { $paged = get_query_var('paged'); }
       elseif ( get_query_var('page') ) { $paged = get_query_var('page'); }
       else { $paged = 1; }
   
       $blog = new WP_Query('posts_per_page=3&paged=' . $paged);
       ?>
       ```
   
 * So I added this to my portfolio template changing the $blog variable to $loop
   also inter-grading the array inside the WP_Query. Like so:
 *     ```
       <?php
       if ( get_query_var('paged') ) { $paged = get_query_var('paged'); }
       elseif ( get_query_var('page') ) { $paged = get_query_var('page'); }
       else { $paged = 1; }
   
       $loop = new WP_Query(array(
                       'post_type' => 'project',
                       'posts_per_page=3&paged=') . $paged);
       ?>
       ```
   
 * The code above displays my blog posts, and not my portfolio posts.
 * Any shed of light would be amazing, I know I have to be close to getting it to
   work properly, but I am still missing something.
 * _2nd post – moved by moderator to here:_ Was my post clear enough? If not I can
   reiterate.
    _ [You’re more likely to get answered if you don’t bump – [http://codex.wordpress.org/Forum\_Welcome#No\_Bumping](http://codex.wordpress.org/Forum_Welcome#No_Bumping)]

Viewing 1 replies (of 1 total)

 *  [vtxyzzy](https://wordpress.org/support/users/vtxyzzy/)
 * (@vtxyzzy)
 * [13 years, 5 months ago](https://wordpress.org/support/topic/custom-posts-pagination-1/#post-3508248)
 * I think that you need to change this:
 *     ```
       $loop = new WP_Query(array(
                       'post_type' => 'project',
                       'posts_per_page=3&paged=') . $paged);
       ```
   
 * to this:
 *     ```
       $loop = new WP_Query(array(
                       'post_type' => 'project',
                       'posts_per_page' => 3,
                       'paged' => $paged) );
       ```
   

Viewing 1 replies (of 1 total)

The topic ‘Custom Posts & Pagination?’ is closed to new replies.

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 1 reply
 * 2 participants
 * Last reply from: [vtxyzzy](https://wordpress.org/support/users/vtxyzzy/)
 * Last activity: [13 years, 5 months ago](https://wordpress.org/support/topic/custom-posts-pagination-1/#post-3508248)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
