WordPress.org

Ready to get started?Download WordPress

Forums

Please Help - current_time great or equal to post_date (5 posts)

  1. sikhyouth
    Member
    Posted 7 years ago #

    Hello everyone,

    Could you please help me?

    I just need an "if" statement in php for wordpress, where I can make certain posts display only if the date of the post is greater than the current date.

    This is for future posts, listed on the homepage with their future dates. I do not want to show any post that is not in the present or future (i.e. any posts that have a timestamp of before today's date).

    Thank you very much!

  2. sikhyouth
    Member
    Posted 7 years ago #

    Basically, if this is the SQL i need the WordPress PHP version:

    post_date > '".current_time('mysql')

  3. sikhyouth
    Member
    Posted 7 years ago #

    anybody??? please !!

  4. sikhyouth
    Member
    Posted 7 years ago #

    somebody must have an answer..

  5. sikhyouth
    Member
    Posted 7 years ago #

    ok despite getting no help i found the solution

    <?php
    $posttime = strtotime($post->post_date);
    $currtime = time();
    $today = date('M d',$currtime);
    $postday = date('M d',$posttime);
    if($postday>$today) : ?>

    all posts will have to have a timestamp of later than today's date

    <?php endif; ?>

Topic Closed

This topic has been closed to new replies.

About this Topic