• For a (very basic) theme I’m creating, I’d like to learn how to display the whole post for my most recent post but then just the excerpt for subsequent posts.

    I’ve been reading the Loop page in the codex. http://codex.wordpress.org/The_Loop

    Would this be as simple as specifying “1 post” in the loop here? (If so, how exactly would this be accomplished?)

    <?php while (have_posts()) : the_post(); ?>
     <?php the_content(); ?>
     <?php endwhile; ?>

    Then would I reset the loop counter with rewind_posts() and do it again displaying the excerpts? Not really sure, but that was my guess after reading the Codex. I’m guessing this has been asked, but I couldn’t find it as it was difficult to anticipate the exact wording that would be used.

    Thanks for the help!

Viewing 6 replies - 1 through 6 (of 6 total)
  • Hi

    try this:

    <?php while (have_posts()) : the_post(); ?>
    <h1><?php the_title(); ?></h1>
    <?php  if ($count < 1) { the_content();	}
    $count = $count + 1;
    the_excerpt(); ?>
    <?php endwhile; ?>

    MAC 🙂

    Thread Starter ajwalsh

    (@ajwalsh)

    It works for me! Thanks.

    Thread Starter ajwalsh

    (@ajwalsh)

    Actually, I do still have one issue. I’d like to include a link to “leave a comment” for the full post but “click to continue reading” for the excerpts.

    <?php  if ($count < 1) { the_content();	}
    $count = $count + 1;
    the_excerpt(); ?> <a href="<?php the_permalink() ?>">Click to Continue Reading</a>

    This code understandably shows the “click to continue” on both. What function can I use to enter html into the two different PHP lines?

    Thread Starter ajwalsh

    (@ajwalsh)

    And also, I just noticed that this is actually displaying the excerpt after the full post as well.

    Any more help would be greatly appreciated!

    Thread Starter ajwalsh

    (@ajwalsh)

    I have solved the issues myself. If anyone else is curious about how to do it, I consulted this tutorial:

    http://www.wprecipes.com/datadial-asked-how-can-i-display-1-full-post-and-3-excerpts

    I’m glad you solved your problem.

    Indeed my code was incomplete. In a hurry I didn’t end the condition with the else statement.

    It should have been like this:

    <?php while (have_posts()) : the_post(); ?>
    <h1><?php the_title(); ?></h1>
    <?php  if ($count < 1) { the_content();	$count = $count + 1; }
    else { the_excerpt(); }; ?>
    <?php endwhile; ?>

    But in the end, both solutions use the same logic.

    MAC 🙂

Viewing 6 replies - 1 through 6 (of 6 total)

The topic ‘Quick Question for Displaying Posts’ is closed to new replies.