Show content of first post, display the rest differently (5 posts)

  1. dss
    Posted 10 years ago #

    I've been chewing on a use of the Loop for several days and haven't had much luck.

    I want to show the first post's content, and the remaining index posts as just the title, or excerpt.

    Looking at using multiple loops, and the examples in the codex, I can do this easily when stating the category. There's a great example there, and this works fine.

    Looking at other resources, like '$first=true' it seems just out of reach.

    Is there a simple conditional where I could state:
    if this is the first post: show content
    else do something else

    Seems like it should be a snap, but somehow when addressing the entire blog's posts the examples are limited, and I am certainly not enough of a coder to exrapolate.

    Can someone point me in the right direction please?

  2. Birger J. Nordølum
    Posted 10 years ago #

    This is what you are looking for!

    Birger :)

  3. dss
    Posted 10 years ago #

    Well that certainly is simple to add into the loop.

    But naturally I'm a little confused...

    if ($loopcounter % 2==0)

    I'd like it to allow a piece of the loop's display to enter into the equasion for only the first post:

    an example:

    if ($loopcounter %1==0) {
    Do this in the loop
    Do that in the loop

    So that only the first post (post number one) shows the_content
    and the remaining 24 index entries only show the_title

    What am I doing wrong?

  4. dss
    Posted 10 years ago #

    Ok, I sorted it out...

    Here's what I came up with:

    if (have_posts()) : while (have_posts()) : the_post(); $loopcounter++;

    if ($loopcounter == 1) {

    Do your thing

    } else {

    Do something else

    And it's working just fine...

    Thank you!

  5. Birger J. Nordølum
    Posted 10 years ago #

    Just glad to help :D

    Birger :)

Topic Closed

This topic has been closed to new replies.

About this Topic