WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am looking for a plugin or a way to list first five posts as new. It should be just a small picture added in the index.php. Any ideas of how I could achieve this? Thanks!

share|improve this question
up vote 0 down vote accepted

This is pretty easy.

//Include this above your loop
$i = 0; //Counter


    //include this in your loop
    if($i <= 5)
        echo "<img src='http://urltoinewimage' alt='Image Title' />";
    //Stop including in your loop

endwhile; else:
share|improve this answer
I should include this into index.php? Shouldnt i wrap it up somehow? Or just paste it like this? – user385917 Sep 19 '11 at 7:02
See the latest edit. Include only the specific parts inside index.php. – Brian Fegter Sep 19 '11 at 13:18

use custom query for first 5 latest posts.

query_posts( 'posts_per_page=5', 'orderby' => 'date', 'order' => 'DESC' );

The execute the query as usual and while displaying you can show them in a separate container or wherever you want to. Also, apply a CSS class with each post title (or whatever you want to target) and finally in your CSS you may show the image. Instead you can also use HTML IMG tag to show the image. Choice is all yours.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.