Separate Latest Post (2 posts)

  1. neoian2
    Posted 8 years ago #

    I would like to make the latest post on my website be in a differently styled box and show as an excerpt. I would like the remaining posts on the front page to be shown in full and all styled differently than the first post but all the same.

    How do I accomplish this?

  2. Kafkaesqui

    Posted 8 years ago #

    In The Loop you can test for the first (latest) post by comparing the current $post object in The Loop with the first post from the $posts object, and then modify how you display your posts based on this:

    <?php if( is_home() && ($post == $posts[0]) ) : ?>
    <div class="firstpost">
    <?php the_excerpt(); ?>
    <?php else : ?>
    <div class="post">
    <?php the_content(); ?>
    <?php endif; ?>

    Also note this is an oft-asked question:

Topic Closed

This topic has been closed to new replies.

About this Topic


No tags yet.