The Support Forums will be in read-only mode for a scheduled maintenance window on 01 September 2016 14:00 UTC - 20:00 UTC. More information.

Custom Post Type Single Loop Outputting Wrong Post (2 posts)

  1. beefchimi
    Posted 4 years ago #

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


  2. Paperback Design
    Posted 4 years ago #

    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.

Topic Closed

This topic has been closed to new replies.

About this Topic