Title: Custom Post Type Single Loop Outputting Wrong Post
Last modified: August 20, 2016

---

# Custom Post Type Single Loop Outputting Wrong Post

 *  [beefchimi](https://wordpress.org/support/users/beefchimi/)
 * (@beefchimi)
 * [13 years, 11 months ago](https://wordpress.org/support/topic/custom-post-type-single-loop-outputting-wrong-post/)
 * I have been unable to get my single-portfolio.php template to behave properly.
 * So I have a custom post type called portfolio. I am displaying all of those posts
   in the front-page.php and it works perfectly fine. Here is the loop for the front-
   page.php:
 * [http://pastie.org/4268087](http://pastie.org/4268087)
 * For the life of my however, I cannot get the right post to show up in my single-
   portfolio.php template.
 * Basically, if I go to one of my posts (so for example, lets say [http://example.com/portfolio/test-post/](http://example.com/portfolio/test-post/))
   I end up with a single post page that displays the wrong post (so instead of “
   test-post” I get “wrong-post”). No matter what post I open up, it will be the
   exact same post that is displayed (“wrong-post”). If I set the posts_per_page
   to infinite, it will show me all of the posts.
 * I have tried many different Loops. I have tried the exact same loop as shown 
   above, as well as the default custom post type loop found in the WordPress Codex.
 * Any suggestions on how to solve this?
 * Thanks,

Viewing 1 replies (of 1 total)

 *  [Paperback Design](https://wordpress.org/support/users/paperback-design/)
 * (@paperback-design)
 * [13 years, 9 months ago](https://wordpress.org/support/topic/custom-post-type-single-loop-outputting-wrong-post/#post-2898778)
 * I had the same issue–always the same wrong post, being displayed, and what finally
   worked for me was stripping back the loop to this simple version:
 *     ```
       <?php if (have_posts()) : while (have_posts()) : the_post(); ?>
       			do stuff
       <?php  endwhile; endif; ?>
       ```
   
 * I know that’s basic, but it worked for me.

Viewing 1 replies (of 1 total)

The topic ‘Custom Post Type Single Loop Outputting Wrong Post’ is closed to new 
replies.

## Tags

 * [custom post type](https://wordpress.org/support/topic-tag/custom-post-type/)
 * [loop](https://wordpress.org/support/topic-tag/loop/)
 * [single](https://wordpress.org/support/topic-tag/single/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 1 reply
 * 2 participants
 * Last reply from: [Paperback Design](https://wordpress.org/support/users/paperback-design/)
 * Last activity: [13 years, 9 months ago](https://wordpress.org/support/topic/custom-post-type-single-loop-outputting-wrong-post/#post-2898778)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
