• I’m trying to put the get_posts function in the header template to call posts 9-16 by using this:

      <?php
      $posts = get_posts('numberposts=8&offset=8');
      foreach ($posts as $post):
      setup_postdata($post);
      ?>

    • "><?php the_title() ?>
    • <?php endforeach; ?>

    It works well, but the problem is when I use it, no matter which post I’m clicking on it always shows the 9th most recent post (the number of posts that I have offset get_posts by).

    Though the title in the browser displays correctly as the title of the post I clicked on, the Post title and post content displayed on the page always belongs to the 9th most recent post.

    Please help me on how I can avoid this…

Viewing 3 replies - 1 through 3 (of 3 total)
  • I am not sure… just a thought. Why do you put the code in the header.php? Since the same header is called for everything, maybe the offset is in effect on every page of yours.
    What if you move the code to the index.php or wherever you want to use it?

    Thread Starter sooeydoo

    (@sooeydoo)

    I just tried that by including the code in single.php, but again it keeps showing the same post on every post’s page. But this time it shows the 16th post instead of the 9th.

    I put it on the header because I want to put a three column table in the header before the sidebar splits the page into two. One column would have the most recent 8 posts which I call using get_archives(postbypost), and a second column would have the posts 9-16 which is what I’m trying to call using get_posts.

    So, I’d prefer using it in the header.

    Thread Starter sooeydoo

    (@sooeydoo)

    Anybody has any clue why this is happening? Help would be much appreciated indeed.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘using get_posts() always show the same post’ is closed to new replies.