Title: Loop based on week&#8230;
Last modified: August 19, 2016

---

# Loop based on week…

 *  [nslatter](https://wordpress.org/support/users/nslatter/)
 * (@nslatter)
 * [17 years, 10 months ago](https://wordpress.org/support/topic/loop-based-on-week/)
 * I need to setup a loop that pulls by day for 7 days only. In other words, I only
   want this week’s (starting on Monday) posts to show up as the days pass. So on
   Monday, only Monday’s post will show up. On Tuesday, Monday and Tuesday’s posts
   will show up. So forth and so on through Saturday which will eventually have 
   6 posts showing. Then on the next Monday, the number of posts showing up will
   start over at one, working its way to six.
 * Is this possible? If so, can someone walk me through how to do it?
 * Thanks!

Viewing 1 replies (of 1 total)

 *  Thread Starter [nslatter](https://wordpress.org/support/users/nslatter/)
 * (@nslatter)
 * [17 years, 10 months ago](https://wordpress.org/support/topic/loop-based-on-week/#post-768598)
 * I figured out an option. I’m not sure how pretty it is because I know little 
   about PHP but here is what I did in case, by some chance, someone else would 
   like to do it as well — or if anyone would like to tell me that I can do this
   easier.
 *     ```
       <?php $today = date("l"); ?>
   
       <?php if ($today == Monday): ?>
   
       <?php $my_query = new WP_Query('showposts=1');?>  
   
       <?php elseif ($today == Tuesday): ?>
   
       <?php $my_query = new WP_Query('showposts=2');?>    
   
       <?php elseif ($today == Wednesday): ?>
   
       <?php $my_query = new WP_Query('showposts=3');?>    
   
       <?php elseif ($today == Thursday): ?>
   
       <?php $my_query = new WP_Query('showposts=4');?> 
   
       <?php elseif ($today == Friday): ?>
   
       <?php $my_query = new WP_Query('showposts=5');?> 
   
       <?php elseif ($today == Saturday): ?>
   
       <?php $my_query = new WP_Query('showposts=6');?> 
   
       <?endif; ?>
       ```
   
 * Then followed it with the normal WP_Query loop:
 *     ```
       <?php while ($my_query->have_posts()) : $my_query->the_post();  $do_not_duplicate = $post->ID;?>
   
       <a href="<?php the_permalink() ?>" class="contentitle" title="<?php the_title(); ?>"><?php the_title(); ?></a>
   
       on <?php the_time('d. M Y') ?> in <?php the_category(','); ?>.
   
       <?php the_content("Continue reading –" . the_title('&nbsp;', '´', false)); ?> 
   
       <?php endwhile; ?>
       ```
   

Viewing 1 replies (of 1 total)

The topic ‘Loop based on week…’ is closed to new replies.

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 1 reply
 * 1 participant
 * Last reply from: [nslatter](https://wordpress.org/support/users/nslatter/)
 * Last activity: [17 years, 10 months ago](https://wordpress.org/support/topic/loop-based-on-week/#post-768598)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
