• 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

    (@nslatter)

    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.