WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] post wizardry (10 posts)

  1. stabani
    Member
    Posted 8 years ago #

    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?

  2. moshu
    Member
    Posted 8 years ago #

    You shoud probably read about the examples of multiple loops here http://codex.wordpress.org/The_Loop .

  3. davidchait
    Member
    Posted 8 years ago #

    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... ;)

    -d

  4. stabani
    Member
    Posted 8 years ago #

    they are both on the same page... aka

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

  5. stabani
    Member
    Posted 8 years ago #

    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?

  6. stabani
    Member
    Posted 8 years ago #

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

  7. stabani
    Member
    Posted 8 years ago #

    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?

  8. davidchait
    Member
    Posted 8 years ago #

    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. ;)

    -d

  9. stabani
    Member
    Posted 8 years ago #

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

  10. iand
    Member
    Posted 8 years ago #

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.