Running 3.5.1. Is there an easy way to display my most recent post in its entirety and only display excerpts for my older posts on my home page?
1 Answer
This is the basic idea behind what you want. Extend/Customize to your liking.
if ( have_posts() ) :
while ( have_posts() ) :
the_post();
the_title();
// Incrementing a not instantiated variable results in 1
// so there's no need to set it to 0 beforehand
if ( 0 < $is_first_post++ ) the_excerpt();
else the_content();
endwhile;
endif;
Or if you want to ommit the compare and the increment operations:
if ( have_posts() ) :
the_post();
the_title();
the_content();
while ( have_posts() ) :
the_post();
the_title();
the_excerpt();
endwhile;
endif;
// EDIT to get the one-and-only most recent post in full only:
if (have_posts()) {
if (2 > get_query_var('paged')) {
the_post();
the_title();
the_content();
}
while (have_posts()) {
the_post();
the_title();
the_excerpt();
}
}
-
+1 for example, but won't your second example show both
the_content()
andthe_excerpt()
of the first post? Mar 15, 2013 at 13:06 -
No, it does not. Within the loop I first fetch the next post and then print the title and excerpt.– tfrommenMar 15, 2013 at 13:09
-
1
-
1Hm? Why is that? Whatever you put inside the
while
loop should get called (and thus be displayed). If you still have the problem, and with removing the above code everything is working fine, maybe post a new question, so you can provide us with your code. I'm positive we find a solution for your problem.– tfrommenMar 28, 2013 at 16:06 -
1Hey @Jane, please see my updated answer. I didn't understand 'most recent' globally, meaning the 'one-and-only most recent post'. ;)– tfrommenApr 12, 2013 at 13:35