[resolved] Posts list and the post content template (6 posts)

  1. AidenVennis
    Posted 4 years ago #

    I am trying to create a post list in a sidebar and the post content in the center. The post list consist of posts that are in one category, and I add a piece of code that makes that list from a category slug (to prevent breaking when moving to a other wordpress installation).

    My problem is that it doesn't show the content of the post when I click a link in the sidebar. Problem example: http://cccp.de-kleijn.com/?cat=8

    Below is the code of single.php that is used in the above example. What is going wrong here?

    [code moderated - please follow the forum guidelines for posting code]

  2. Michael
    Forum Moderator
    Posted 4 years ago #

    you possibly need to reset the postdata at the end of the foreach loop - http://codex.wordpress.org/Function_Reference/wp_reset_postdata

  3. AidenVennis
    Posted 4 years ago #

    Thanks for the reply alchymyth, but it doesn't seem to work! I added the wp_reset_postdata after the end of the endforeach loop. It still doesn't load right single page :/

  4. AidenVennis
    Posted 4 years ago #

    Sorry about the to long code! You can find the (new updated) code here: http://pastebin.com/HVtaPDwb

  5. Michael
    Forum Moderator
    Posted 4 years ago #

    try to change $posts to something else in here:

    $posts = get_posts( $postlist );
                                            foreach ($posts as $post) : setup_postdata($post); ?>

    for instance:

    $video_posts = get_posts( $postlist );
                                            foreach ($video_posts as $post) : setup_postdata($post); ?>

    if that does not work, try to add wp_reset_query(); before the main loop; for instance here before line 47:

    <?php wp_reset_query(); ?>
    <?php while ( have_posts() ) : the_post(); ?>
  6. AidenVennis
    Posted 4 years ago #

    Thanks alchymyth! That did the trick! Quite stupid of me to not change the variable name since it is reused later, guessed I must have missed that!

Topic Closed

This topic has been closed to new replies.

About this Topic