Support » Fixing WordPress » 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:

    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 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?


Viewing 1 replies (of 1 total)
  • 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.