Support » Themes and Templates » post wizardry

  • Resolved stabani


    i’m trying to make a theme for my site which makes the most latest post show the content while the older ones show the excerpt.

    any idea on how to do this?

Viewing 9 replies - 1 through 9 (of 9 total)
  • You shoud probably read about the examples of multiple loops here .

    You don’t need multiple loops in the slightest. What you WOULD need is to customize the loop in your index.php, and have it output the_content for just the first on the page, and the_excerpt for all others. Just set a variable/flag to false outside the loop, and once you’ve processed one post with the_content set the variable to true, and then testing the variable from then on should always output the_excerpt.

    Yep, you need to know some PHP to do this… 😉


    they are both on the same page… aka

    post1: content
    post2: excerpt
    post3: excerpt
    and so on. all on the same page

    i am wondering if it is possible to use the loop counter perhaps, using if/else statements

    (inside the loop, add the following)

    ‘<?php if ( $postCount=1 ) { ?>
    <div class=”content”>
    <?php } else { ?>
    <div class=”excerpt”>
    <?php } ?>’

    ofcourse, adding the necessary template tags.

    would that work?

    ok, i can understand how to use multiple loops, but how do you make the second loop not show the latest post?

    this code seems to work:

    <?php if ( $postCount == “1” ){ ?>
    add relevant tags and formatting for the first post here
    <?php } else { ?>
    the relevant tags and formatting for the others.
    <?php } ?>

    any thoughts or suggestions otherwise?

    Nope, that’s exactly what I was suggesting. That is the way to go, not multiple loops — there’s no need, as you probably figured out. 😉


    thanks david and moshu! Working now. Thanks a million, you solved a major peice of the puzzle.

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘post wizardry’ is closed to new replies.