The Support Forums will be in read-only mode for a scheduled maintenance window on 01 September 2016 14:00 UTC - 20:00 UTC. More information.

Show Posts in last 3 days (5 posts)

  1. josephgene
    Posted 7 years ago #

    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?


  2. MichaelH
    Posted 7 years ago #

    This code in your loop will print 'this post is within my date limit' if the post date is within the last 3 days:

    $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 ';
  3. josephgene
    Posted 7 years ago #

    <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 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; ?>

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

  4. josephgene
    Posted 7 years ago #


  5. josephgene
    Posted 7 years ago #

    Double bump?^^

Topic Closed

This topic has been closed to new replies.

About this Topic