• Hello everyone. Basically, I’m hoping to find a way to “highlight” the lastest post on my wordpress site. What I want to do is similar to what is occuring on Bartelme Design (http://www.bartelme.at/). The post that is first comes up with a different background style and a specific image next to it. Then, every post following this has a normal style, which is consistant from post 2 onwards.
    So what I want to know is how I can apply a set of styles that only affect the most recent post on a wordpress powered site, and what code I need to make this happen.

    TIA, any help appreciated.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Open your index.php file and look for a line that looks like this (or similare to it):
    <?php if (have_posts()) : while (have_posts()) : the_post(); ?>

    Right above that, put something like this:
    <?php $FirstPost = True; ?>

    Now, just *after* the if line, find where the posts begin, what you are looking for is some kind of div tag that contains the individual post. Ususaly it has a class of “post”

    You’ll want to replace the line with something like this:
    <?php
    if ($FirstPost) {
    echo ('<div class="post firstpost">');
    $FirstPost = False;
    } else {
    echo ('<div class="post">');
    }?>

    Then you just need to add .firstpost to your CSS and style it the way you want.

    -tg

    Thread Starter icespectre

    (@icespectre)

    Heh, thanks a lot man!
    Cheers.

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

The topic ‘Most Recent Post Highlighted?’ is closed to new replies.