[resolved] Giving last post a different style from recent posts (4 posts)

  1. neuville
    Posted 8 years ago #

    Hello there,
    I'm trying to change the template to one of my blogs.

    I'd like to give two different styles to the last post (the last article posted) and to the 'n' recent posts featured in home page.

    the last post should be entirely visible.

    the recent 'n' posts should feature a title, a thumbnail and some other stuff.

    I've the thumbnail stuff up and running, but i'm not able to add a custom style to the last post

    anyone can help? thank you a lot in advance!

  2. Clicknathan
    Posted 8 years ago #

    By last post I'm assuming you mean the latest post, or the one at the top of your blog. If so, here's some code you can use to do what you're looking for:

    <?php $postnum = 0; if (have_posts()) : ?>
    <?php while (have_posts()) : $postnum = $postnum + 1; the_post(); ?>
    <?php if ($postnum == 1 ) { ?>
    <p>Add the HTML you want for the latest post here.</p>
    <?php } ?>
    <?php if ($postnum >= 2 ) { ?>
    <p>Add the HTML you want for the remaining posts here.</p>
    <?php } ?>
    <?php endwhile; ?>
  3. neuville
    Posted 8 years ago #

    It works fine, Clicknathan

    Thank you a lot! :-)

  4. simonsharks
    Posted 7 years ago #

    I have posted some code to determine the first or last post at Last Post in The Loop

Topic Closed

This topic has been closed to new replies.

About this Topic