Title: using get_posts() always show the same post
Last modified: August 18, 2016

---

# using get_posts() always show the same post

 *  [sooeydoo](https://wordpress.org/support/users/sooeydoo/)
 * (@sooeydoo)
 * [20 years, 6 months ago](https://wordpress.org/support/topic/using-get_posts-always-show-the-same-post/)
 * 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 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)

 *  [moshu](https://wordpress.org/support/users/moshu/)
 * (@moshu)
 * [20 years, 6 months ago](https://wordpress.org/support/topic/using-get_posts-always-show-the-same-post/#post-294195)
 * 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](https://wordpress.org/support/users/sooeydoo/)
 * (@sooeydoo)
 * [20 years, 6 months ago](https://wordpress.org/support/topic/using-get_posts-always-show-the-same-post/#post-294200)
 * 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](https://wordpress.org/support/users/sooeydoo/)
 * (@sooeydoo)
 * [20 years, 6 months ago](https://wordpress.org/support/topic/using-get_posts-always-show-the-same-post/#post-294285)
 * 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.

## Tags

 * [get_posts](https://wordpress.org/support/topic-tag/get_posts/)
 * [offset](https://wordpress.org/support/topic-tag/offset/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 3 replies
 * 2 participants
 * Last reply from: [sooeydoo](https://wordpress.org/support/users/sooeydoo/)
 * Last activity: [20 years, 6 months ago](https://wordpress.org/support/topic/using-get_posts-always-show-the-same-post/#post-294285)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
