Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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

2 Answers 2

up vote 0 down vote accepted

This is pretty easy.

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

if(have_posts())while(have_posts())the_post();

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

    the_title();
    the_content();
endwhile; else:
endif;
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

 
discard

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.