WordPress.org

Support

Support » How-To and Troubleshooting » Showing one full article and then excerpts

Showing one full article and then excerpts

  • Hey guys…

    I’d like to have my blog show the first/most recent article in full and then the remaining posts to be excerpts…

    So forexample, if I’ve set my blog to show 20 articles on the front page, then it’ll show 1 full article and then the balance, 19, in excerpts…

    Something like what has been done on this blog: http://www.localvocal.co.za

    I hope you guys can help…

    Regards

Viewing 4 replies - 1 through 4 (of 4 total)
  • Simplest method would be to add a PHP variable into The Loop which increments for each post, like this:

    <?php
    if(have_posts()) : while(have_posts()) : the_post();
    $postcount++;
    ?>

    Then alter the the_content() tag code to test on it, like this:

    <?php
    if($postcount > 1) {
    the_excerpt();
    } else {
    the_content();
    }
    ?>

    You could add a post counter into the loop. Eg: before the loop you set $i=0 and in the loop $i++. Then depending on the value of $i (in your case when $=1) do something with it.

    edit: like kafkaeski said faster

    awesome guys, thanks very much.. i’ll test it out when i get to coding… just wanted 2 make sure it can be done…

    one thing to throw in the mix…

    i want to have 2 loops… basically, if you can imagine… a left panel with a full article in it and then a second div as a right panel with the remaining excerpts/article titles in it… i’d need to loops running right?

    is the above possible with this format?

    Thought I’d add that you can also use the $posts object as a counter of sorts. For that there’s no need for a “count” var; just change the_content() to:

    <?php
    if($post == $posts[0]) {
    the_content();
    } else {
    echo the_excerpt();
    }
    ?>

    EDIT:
    Missed you’re followup with this reply. For a second loop, look at get_posts(). It provides an offset argument which would let you pass over the first (latest) post from your initial loop. Note the information there on setting up a custom loop for processing the posts.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Showing one full article and then excerpts’ is closed to new replies.
Skip to toolbar