Viewing 1 replies (of 1 total)
  • Find
    <?php while(have_posts()) : the_post(); ?>
    Replace with…
    <?php $countposts = 0; while(have_posts()) : the_post(); $countposts++; ?>

    Then wherever you want to do something different…

    <?php if($countposts == 1) {
      // YOUR CODE
    } ?>

    So for example, lets say you have the following piece of HTML…
    <div class="example">
    And you wanted to add a class when it’s the first post, it would then become.
    <div class="example<?php if($countposts == 1) { ?> secondclass<?php } ?>">

    Your HTML then becomes..
    <div class="example secondclass">

    All you need then do is add a CSS definition for that second class in your stylesheet.
    Example:

    .secondclass {
      background-color: #000;
    }

Viewing 1 replies (of 1 total)
  • The topic ‘Styling fist post’ is closed to new replies.