• Is there a way so I can style only the last post? I know that I can style a post by post IDs but I want to style generally all the last post.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Just use a counter to figure that last post, which on a WordPress blog means the latest (or first post displayed).

    <?php
    $count = 0;
    if (have_posts()) {
     while (have_posts()) : the_post();
      $count++;
        if ($count <= 1) {
    //your special stuff
          the_content();
        } else {
          the_content();
        }
     endwhile;
    }
    ?>
    Thread Starter miniimage

    (@miniimage)

    So how do I go about on inserting that? I just insert that code? I know you said that’s for the first post, but the maximum posts per page on my blog is 10.

    Should I do something like this:

    <div class="lastpost">
    
    <?php
    $count = 10;
    if (have_posts()) {
     while (have_posts()) : the_post();
      $count++;
        if ($count <= 10) {
    //your special stuff
          the_content();
        } else {
          the_content();
        }
     endwhile;
    }
    ?>
    
    </div>

    Oh, and thanks!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Customize Last Post’ is closed to new replies.