Support » Fixing WordPress » Posts list and the post content template

  • Resolved AidenVennis

    (@aidenvennis)


    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]

Viewing 5 replies - 1 through 5 (of 5 total)
  • Michael

    (@alchymyth)


    Forum Moderator


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

    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 :/

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

    Michael

    (@alchymyth)


    Forum Moderator


    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(); ?>

    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!

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Posts list and the post content template’ is closed to new replies.