Title: playing with &#8216;the loop&#8217;
Last modified: August 18, 2016

---

# playing with ‘the loop’

 *  [david67](https://wordpress.org/support/users/david67/)
 * (@david67)
 * [20 years, 4 months ago](https://wordpress.org/support/topic/playing-with-the-loop/)
 * Hello,
    i’m trying to customise my index page with ‘the loop’, what i want is
   to display 5 full posts and then only 5 resumes of posts (and then on the next
   pages, only resumes ; i’m not sure that this last idea is possible btw)
 * i know i need to use the the_excerpt() instead of the the_content(), but what
   gives me problems is the loop,
 * i tried to find examples on Rhymed code ( [http://rhymedcode.net/1001-wordpression-loops/](http://rhymedcode.net/1001-wordpression-loops/))
   or the codex, but it’s a bit too hard for my codec skills, can someone help me
   with the loop ?
 * thanks!

Viewing 11 replies - 1 through 11 (of 11 total)

 *  [Joshua Sigar](https://wordpress.org/support/users/alphaoide/)
 * (@alphaoide)
 * [20 years, 4 months ago](https://wordpress.org/support/topic/playing-with-the-loop/#post-319174)
 * 1. Go to “Options” -> “Reading” and set “Show at most” to “10 posts.”
 * 2. Copy “index.php” as “paged.php”
 * In “index.php”
    3. Before the following line,
 * `if( have_posts() ) : `
 * …add the following.
 * `<?php $wp_query->set( 'showposts', '5' ); ?>
    <?php query_posts( '' ); ?>
 * 4. Inside the Loop, make sure to call the template tag “the_content()”
 * 5. Still in “index.php,” add another Loop after the first one.
 * `<?php $posts = get_posts( "numberposts=5&offset=5″ ); ?>
    <?php if( $posts ):?
   >
 * `<div class="section" id="theRest">
    <h2>The rest...</h2> <?php foreach( $posts
   as $post ) : setup_postdata( $post ); ?> <div> // call "the_excerpt" and whatever
   you need </div>
 * `<?php endforeach; ?>;`
 * `</div>`
 * `<?php endif; ?>`
 * 6. to be continued…
 *  Thread Starter [david67](https://wordpress.org/support/users/david67/)
 * (@david67)
 * [20 years, 1 month ago](https://wordpress.org/support/topic/playing-with-the-loop/#post-319551)
 * thanks for the help,
 * in fact i changed the code to display 1 post then some contest and then 4 else
   posts (5 posts in total)
 * i suceeded to do the first part : display 1 post and after i got a wierd error,
   here is my code :
    ‘ <?php $wp_query->set( ‘showposts’, ‘1’ ); ?> <?php query_posts(”);?
   >
 *  <?php if (have_posts()) : ?>
 *  <?php while (have_posts()) : the_post(); ?>
 *  <div class=”post” id=”post-<?php the_ID(); ?>”>
    <h2>” rel=”bookmark” title=”
   Permanent Link to <?php the_title(); ?>”><?php the_title(); ?>
   </h2>
    <div id
   =”postmetadata”><?php the_time(‘F jS, Y’) ?>. Posted by <?php the_author() ?>
   <?php edit_post_link(‘Edit’,'[‘,’]’); ?> **Read more about : **<?php the_category(‘,’)?
   ></div>
 *  <div class=”entry”>
    <?php the_content(‘Read the rest of this entry »’); ?> 
   </div>
 *  <?php comments_popup_link(‘Post a Comment’, ‘1 Comment’, ‘% Comments’); ?></
   div>
    </div>
 *  <?php endwhile; ?>
 *  <div class=”navigation”>
    <div class=”alignleft”><?php next_posts_link(‘« Previous
   Entries’) ?></div> <div class=”alignright”><?php previous_posts_link(‘Next Entries»’)?
   ></div> </div>
 *  <?php else : ?>
 *  <h2 class=”center”>Not Found</h2>
    <p class=”center”>Sorry, but you are looking
   for something that isn’t here. <?php include (TEMPLATEPATH . “/searchform.php”);?
   >
 *  <?php endif; ?>
 * <?php $posts = get_posts( “numberposts=4&offset=1? ); ?>
    <?php if( $posts ) :?
   > <?php foreach( $posts as $post ) : setup_postdata( $post ); ?>
 *  <div class=”post” id=”post-<?php the_ID(); ?>”>
    <h2>” rel=”bookmark” title=”
   Permanent Link to <?php the_title(); ?>”><?php the_title(); ?>
   </h2>
    <div id
   =”postmetadata”><?php the_time(‘F jS, Y’) ?>. Posted by <?php the_author() ?>
   <?php edit_post_link(‘Edit’,'[‘,’]’); ?> **Read more about : **<?php the_category(‘,’)?
   ></div>
 *  <div class=”entry”>
    <?php the_content(‘Read the rest of this entry »’); ?> 
   </div>
 *  <?php comments_popup_link(‘Post a Comment’, ‘1 Comment’, ‘% Comments’); ?></
   div>
    </div>
 * <?php endforeach; ?>;
    <?php endif; ?>
 *  </div>
 * <?php get_sidebar(); ?>
 * <?php get_footer(); ?>
    ‘
 *  Thread Starter [david67](https://wordpress.org/support/users/david67/)
 * (@david67)
 * [20 years, 1 month ago](https://wordpress.org/support/topic/playing-with-the-loop/#post-319552)
 * btw what are backticks ?
    //Put code in between `backticks`.
 *  [Chris_K](https://wordpress.org/support/users/handysolo/)
 * (@handysolo)
 * [20 years, 1 month ago](https://wordpress.org/support/topic/playing-with-the-loop/#post-319553)
 * backtick = backward facing tick. On most full keyboards, it is up next to the
   left of the “1” key.
 *  Thread Starter [david67](https://wordpress.org/support/users/david67/)
 * (@david67)
 * [20 years, 1 month ago](https://wordpress.org/support/topic/playing-with-the-loop/#post-319554)
 * are backticks those : ‘
    i’m using an azerty keyboard 😉
 * on the left of the one key i got this : ²
 *  [Chris_K](https://wordpress.org/support/users/handysolo/)
 * (@handysolo)
 * [20 years, 1 month ago](https://wordpress.org/support/topic/playing-with-the-loop/#post-319555)
 * This critter: `
 *  [Kafkaesqui](https://wordpress.org/support/users/kafkaesqui/)
 * (@kafkaesqui)
 * [20 years, 1 month ago](https://wordpress.org/support/topic/playing-with-the-loop/#post-319556)
 * For large blocks of code the better option is to paste your code at a pastebin
   site and link to it here:
 * [http://pastebin.co.uk](http://pastebin.co.uk)
    [http://pastebin.com](http://pastebin.com)
   [http://paste.uni.cc](http://paste.uni.cc)
 *  Thread Starter [david67](https://wordpress.org/support/users/david67/)
 * (@david67)
 * [20 years, 1 month ago](https://wordpress.org/support/topic/playing-with-the-loop/#post-319557)
 * thanks for the links !
 * i tried this :
    [http://pastebin.co.uk/602](http://pastebin.co.uk/602)
 * in fact i have 5 posts per page, i display one post some links and then 4 posts
 * the display of the 1 post is ok, but i have a problem to display the 4 others,
 * i tried to start the 4posts_loop but it don’t work,
    <?php $posts = get_posts(“
   numberposts=4&offset=1? ); ?> <?php if( $posts ) : ?>
 * i got this error :
    Parse error: parse error, unexpected $ in /home/rollerne/
   public_html/v3/wp-content/themes/rn/index.php on line 102
 * and 102 is an empty line !
 * help 😉
 * thanks!
 *  Thread Starter [david67](https://wordpress.org/support/users/david67/)
 * (@david67)
 * [20 years, 1 month ago](https://wordpress.org/support/topic/playing-with-the-loop/#post-319563)
 * anyone ? :/
 *  Thread Starter [david67](https://wordpress.org/support/users/david67/)
 * (@david67)
 * [20 years ago](https://wordpress.org/support/topic/playing-with-the-loop/#post-319574)
 * hi have a little question, thanks.
 * is the <?php $posts = get_posts( “numberposts=5&offset=5″ ); ?> request correct?
   i get a parse error using it :/
 * David.
 *  [aylia](https://wordpress.org/support/users/aylia/)
 * (@aylia)
 * [20 years ago](https://wordpress.org/support/topic/playing-with-the-loop/#post-319575)
 * Try without the $posts=
    I use get_posts and don’t have that anywhere…
 * EDIT: hang on thats not true at all! I will have a look at my index for you..
 * try putting the get_posts section before your `<?php else : ?>` and `<?php endif;?
   >`
 * I’ve put my code up at [http://pastebin.co.uk/619](http://pastebin.co.uk/619)
   
   not sure it will help as it is a bit of a mess but it definitly works!

Viewing 11 replies - 1 through 11 (of 11 total)

The topic ‘playing with ‘the loop’’ is closed to new replies.

## Tags

 * [loop](https://wordpress.org/support/topic-tag/loop/)

 * 11 replies
 * 5 participants
 * Last reply from: [aylia](https://wordpress.org/support/users/aylia/)
 * Last activity: [20 years ago](https://wordpress.org/support/topic/playing-with-the-loop/#post-319575)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
