Forums

Limits by Date (2 posts)

  1. be_rad
    Member
    Posted 3 years ago #

    I run a few loops on various parts of my website. One pulls posts on events that are dated. I am able to limit the query_post to that category. How do I limit the posts displayed to a specific date? I am currently limiting it by only pulling a specific number of posts.

    you can view it here: http://www.pdxjazz.com/events/

    This way after the event date the post will no longer post to my page? Thus the event that was on 10/14 will be visible until 10/14, but on 10/15 the post will not.

    Thanks for you help.

  2. MichaelH
    Volunteer
    Posted 3 years ago #

    This code can be used in your loop for posts that are so may days old date (in this case 46 days)

    <?php
    $mylimit=46 * 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 ';
    }
    ?>

Topic Closed

This topic has been closed to new replies.

About this Topic