Forums

Creating an Automatic Post Excerpt Display For Front Page (2 posts)

  1. CallUp
    Member
    Posted 1 month ago #

    I would like to set up my Loop to display in full the first three posts, and then for the remainder of the posts (i.e. posts 4, 5, 6, ...) only display the title and a 75 word excerpt from each.

    That way I can just hide the excerpt/more option from the user's add new post functionality and get a consistent front page display.

    Can someone shed some light on how to pull this off.

    I'm guessing I'll need a global count variable to keep track of the number of posts being displayed, but what function would I use? Some variation of content()?

  2. tugbucket
    Member
    Posted 1 month ago #

    // this loop shows #1-3 in full
    
    <?php $posts=query_posts($query_string . '&posts_per_page=3'); ?>
    <?php if (have_posts()) : ?>
    <?php while (have_posts()) : the_post(); ?>
    <?php the_content('read more'); ?>
    <?php endwhile; ?>
    <?php else : ?>
    <p>Sorry, but you are looking for something that isn't here.</p>
    <?php endif; ?>
    
    // this loop then shows #4-6 with only the excerpt
    
    <?php $posts=query_posts($query_string . '&posts_per_page=3&offset=3'); ?>
    <?php if (have_posts()) : ?>
    <?php while (have_posts()) : the_post(); ?>
    <?php the_excerpt(); ?>
    <?php endwhile; ?>
    <?php else : ?>
    <p>Sorry, but you are looking for something that isn't here.</p>
    <?php endif; ?>

    if your familiar with the loop this is not that tough. Changing the length of the excerpt is a little extra though.

    http://jarretcade.net/changing-the-default-wordpress-excerpt-length

Reply

You must log in to post.

About this Topic