WordPress.org

Ready to get started?Download WordPress

Forums

Separate Latest Post (2 posts)

  1. neoian2
    Member
    Posted 6 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 6 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(); ?>
    </div>
    
    <?php else : ?>
    
    <div class="post">
    <?php the_content(); ?>
    </div>
    
    <?php endif; ?>

    Also note this is an oft-asked question:
    http://wordpress.org/search/different+first+post?forums=1
    http://wordpress.org/search/different+latest+post?forums=1

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.