• Hi guys, need some help with an events page I’m making. Basically I want to only display posts which are in the past for the “Past Events” page and posts which are in the future for the “Future Events” page. So, two scripts in all.

    This is my query for the “Future Events” page:
    <?php query_posts('category_name=events&showposts=10'.'&orderby=date&order=ASC'); ?>

    I’m calling the events category (ID = 10) and sorting it so that the events closest in the future are displayed first. Now I need a way to only get posts which have a date that are at present date or the future (similarily I need a way to display past posts for the “past events” page). Can anyone point me in the right direction? Thank you!

Viewing 1 replies (of 1 total)
  • Thread Starter addnon

    (@addnon)

    Okay so I think I came up with a solution. This is for displaying only future events. I’m not sure how precise it is, but it works. If someone has a better, more professional solution (i.e – a function) please let me know.

    <?php if (strtotime($post->post_date) > strtotime('-1 days')): ?>

Viewing 1 replies (of 1 total)
  • The topic ‘Display posts ONLY if date is in the past/future’ is closed to new replies.