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.

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?

share|improve this question

1 Answer 1

up vote 3 down vote accepted

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();
    }
}
share|improve this answer
    
+1 for example, but won't your second example show both the_content() and the_excerpt() of the first post? –  David Gard Mar 15 '13 at 13:06
    
No, it does not. Within the loop I first fetch the next post and then print the title and excerpt. –  t f Mar 15 '13 at 13:09
1  
Ah, of course, the_post() will do the job as required. –  David Gard Mar 15 '13 at 13:58
1  
Hm? 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. –  t f Mar 28 '13 at 16:06
1  
Hey @Jane, please see my updated answer. I didn't understand 'most recent' globally, meaning the 'one-and-only most recent post'. ;) –  t f Apr 12 '13 at 13:35

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.