how to only show future posts in a cat (11 posts)

  1. rvreeland
    Posted 7 years ago #

    I have a category for events which is set up to display posts in reverse order so that the most upcoming events show first. I've already figured out how to display future posts, but now my concern is how to not show posts from the past on the home page once the events have already gone by?

    For instance, there are a list of events, the top one being on August 25th. August 25th passes and that event/post will remain there but I want it to disappear so that the most upcoming event is always displayed first.

    Any suggestions?

    I would simply delete the events once they occur but I'd like to keep all of them for viewing on the category page. For this I'd simply like to create something to use in the events category loop I've made on the home page.

  2. mzah8
    Posted 7 years ago #

    I have this exact same need. I am trying out different things at the moment but if anyone would like to post an exact solution that would be great.

  3. davidbaldwin
    Posted 7 years ago #

    I need the exact same thing, I didn't see any reason to use a plug-in when I could just set the post date to whenever the event date is, and whenever that date past, the post would remove itself from the list.

    I know how to do this, but I don't know how to get rid of the events that have gone by.

  4. davidbaldwin
    Posted 7 years ago #

    Is there no way to accomplish this?

    I am running a simple events, where I just set a future post date and the event appears, I just wish it would disappear when the time is up.

    there are no plugins running for the events, and I'd like to keep it that way.

    Can I request a future post/old post switch for a particular category?


  5. Dazzer
    Posted 7 years ago #

    AFAIK this is not a feature in wordpress. If you don't want to use a plugin, then you'll have to hack the template.

  6. mores
    Posted 7 years ago #

    probably something like if (get_the_date()>now()){ display posst} inside the loop.

  7. Jauhari
    Posted 7 years ago #

    I try to use get_the_date() and got this error
    Fatal error: Call to undefined function get_the_date() in

    Why? and how to fix it?

  8. quirksmode
    Posted 7 years ago #

    Having the same problem, why does the get_the_date function not work?

  9. Morgan
    Posted 7 years ago #

    You can use get_the_time() instead.

    Also, in the loop I used something like:

    if ( strtotime(get_the_time()) > strtotime('yesterday') ) {
        // display stuff

    to get the functionality described in this post.

  10. TrishaM
    Posted 7 years ago #

    I'm not a coder, but it seems like you might consider using a custom field for this, perhaps call it "remove-date"?

    Then check the current date against the value of this custom field to determine if it should be displayed or not.....

    Perhaps a 'real' coder can help with writing a function for this - then you could put that in your theme's functions.php file and call it when performing the loop that would list posts for that category....

  11. millik1
    Posted 6 years ago #

    I manage a number of websites where I've implemented WordPress driven gig / event lists. There are two headings 'Gigs' where I only display future posts - and 'Previous Gigs' where I only display past posts.

    If this is what you're after, then full details are here ...


Topic Closed

This topic has been closed to new replies.

About this Topic