• How do i have wordpress show posts from a date range, say, the last 3 days, as opposed to the last 3 posts?

    Can this happen?

    -Joe!

Viewing 4 replies - 1 through 4 (of 4 total)
  • This code in your loop will print ‘this post is within my date limit’ if the post date is within the last 3 days:

    <?php
    $mylimit= 3 * 86400; //days * seconds per day
    $post_age = date('U') - get_post_time('U');
    if ($post_age <= $mylimit) {
    echo 'this post is within my date limit ';
    }
    ?>

    Thread Starter josephgene

    (@josephgene)

    <div id="container">
    <div id="main-col">
    <h3 class="blog-title"><a href="<?php echo get_option('home'); ?>/"><em><?php bloginfo('name'); ?></em></a></h3>
    <span class="logo-spacer"></span>
    <?php if (have_posts()) : while (have_posts()) : the_post(); ?>
    	<div class="post" id="post-<?php the_ID(); ?>">
        	<h2><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>"><?php the_title(); ?></a></h2>
            <div class="date"><span class="year"><?php the_time('Y') ?></span> <?php the_time('F') ?> <span class="day"><?php the_time('jS') ?></span></div>
            <div class="comments"><span class="comment-count"><?php comments_popup_link('0', '1', '%'); ?></span> Comments</div>
            <br clear="all" />
            <div class="excerpt"><?php the_content('Read the rest of this entry &raquo;'); ?></div>
        </div>
        <div class="filed">Filed under <?php the_category(', ') ?> by <?php the_author() ?> on <?php the_time('F jS, Y') ?> @ <?php the_time() ?> </div>
        <span class="spacer"></span>
    <?php endwhile; else: ?>
    <p><?php _e('Sorry, no posts matched your criteria.'); ?></p>
    <?php endif; ?>
        </div>

    So if this is my loop on home.php – then the code goes where?

    Thread Starter josephgene

    (@josephgene)

    bump^^?

    Thread Starter josephgene

    (@josephgene)

    Double bump?^^

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Show Posts in last 3 days’ is closed to new replies.