Support » Fixing WordPress » Show recent posts on a list and single out 1st item for special formating

  • I am working on my WordPress theme and I was wondering how I can setup a loop so it displays the excerpts of the most recent posts from category but separate the very most recent post so I can format it differently (make it stand out from the rest of list of posts).

    I am working on a Magazine like format so the most recent article from say Science will be displayed bigger and for the rest I want to show them smaller. I can do the formatting for CSS just fine with no sweat but the loop code is what trouble me.

    I was able to pull the most recent post list with the code displayed here (Codex > Loop) but how can single out the very first item so I can format it differently?
    Any ideas? any help is much appreciated!

Viewing 1 replies (of 1 total)
  • hi

    Some code I came up with yesterday along that line. This goes inside a WP loop

    if( ($wp_query->current_post == 0) && !isset($wp_query->query[paged])) ) {
                    ===== code for first post =======
    } else {
                    ===== code for the rest of the posts =======

    $wp_query-> current_post == 0 means the first post in the current page

    !isset($wp_query->query[paged])) if that is true it means we are on the first page of posts, in case we have a set of post pages. Without that, the 1st post code would be applied to the 1st post on every page in the set, whereas we only want it applied to the first post of page 1 in a possible set.

Viewing 1 replies (of 1 total)
  • The topic ‘Show recent posts on a list and single out 1st item for special formating’ is closed to new replies.