WordPress.org

Support

Support » How-To and Troubleshooting » [Resolved] Giving last post a different style from recent posts

[Resolved] Giving last post a different style from recent posts

  • 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!

Viewing 3 replies - 1 through 3 (of 3 total)
  • 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; ?>

    It works fine, Clicknathan

    Thank you a lot! 🙂

    simonsharks

    @simonsharks

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

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘[Resolved] Giving last post a different style from recent posts’ is closed to new replies.
Skip to toolbar