I've used this technique in the past but can't seem to find my code snippet! Booo!
OK, I'm displaying my 5 most recent posts on the home page of my website. I want the entire post (the_content) to display for my most recent post. Then I want the_excerpt to display for the 4 other posts. So like this:
<strong>Title of First Article</strong>
the_content
<strong>Title of 2nd Article</strong>
the_excerpt
<strong>Title of 3rd Article</strong>
the_excerpt
So on and so forth...you guys get the idea. Thanks!
Sébastien | French WordpressDesigner answers:
[[LINK href="http://codex.wordpress.org/Function_Reference/query_posts"]]http://codex.wordpress.org/Function_Reference/query_posts[[/LINK]]
<?php
query_posts("posts_per_page=1" );
while ( have_posts() ) : the_post();
the_title();
the_content();
endwhile;
wp_reset_query();
query_posts("posts_per_page=2&offset=1" );
while ( have_posts() ) : the_post();
the_title();
the_excerpt();
endwhile;
?>
Jurre Hanema answers:
Sorry, but I don't think Sébastiens solution is very good. It should not be necessary to query for posts twice.
If you already have posts loop in place, just add a loop counter and a simple check so that everything looks like this:
$i = 0;
while(have_posts)):
the_post();
the_title();
if($i == 0)
{
the_content();
} else
{
the_excerpt();
}
$i++;
endwhile;