Title: Last X Posts problem
Last modified: August 18, 2016

---

# Last X Posts problem

 *  [edyuban](https://wordpress.org/support/users/edyuban/)
 * (@edyuban)
 * [21 years, 1 month ago](https://wordpress.org/support/topic/last-x-posts-problem/)
 * I’m trying to display the last seven entries on my web site and almost have it
   except that, rather than displaying the author of each entry, it gives me the
   credit. If someone could take a look at this and tell me what I’m doing wrong,
   I’d really appreciate it.
 * I have something similar in the main index area which works fine, just not in
   the sidebar.
 * By the way, the new WordPress is unicorns, I must say.
 * <?php
    $posts = get_posts(‘numberposts=7’); foreach ($posts as $post) : ?> <img
   src=”/images/authors/<?php the_author_ID(); ?>.jpg” class=”author_icon”>“><?php
   the_title() ?><br> by <?php the_author(); ?> <?php endforeach; ?>

Viewing 3 replies - 1 through 3 (of 3 total)

 *  [lawtai](https://wordpress.org/support/users/lawtai/)
 * (@lawtai)
 * [21 years, 1 month ago](https://wordpress.org/support/topic/last-x-posts-problem/#post-183568)
 * what do you mean credit?
 *  [Kafkaesqui](https://wordpress.org/support/users/kafkaesqui/)
 * (@kafkaesqui)
 * [21 years, 1 month ago](https://wordpress.org/support/topic/last-x-posts-problem/#post-183580)
 * If you’re running WordPress 1.5, Try this:
 * `<?php
    $posts = get_posts('numberposts=7'); foreach ($posts as $post) : setup_postdata(
   $post); ?> <img src="/images/authors/<?php the_author_ID(); ?>.jpg" class="author_icon"
   ><?php the_title() ?><br> by <?php the_author(); ?> <?php endforeach; ?>
 * If you have 1.2.x, swap
 * `setup_postdata($post);`
 * with
 * `start_wp();`
 *  Thread Starter [edyuban](https://wordpress.org/support/users/edyuban/)
 * (@edyuban)
 * [21 years, 1 month ago](https://wordpress.org/support/topic/last-x-posts-problem/#post-183802)
 * That did it! Woo! You may be the most awesome person alive. Remind me to send
   you cookies.

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Last X Posts problem’ is closed to new replies.

 * 3 replies
 * 3 participants
 * Last reply from: [edyuban](https://wordpress.org/support/users/edyuban/)
 * Last activity: [21 years, 1 month ago](https://wordpress.org/support/topic/last-x-posts-problem/#post-183802)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
