WordPress.org

Support

Support » How-To and Troubleshooting » how to only show future posts in a cat

how to only show future posts in a cat

  • 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.

Viewing 10 replies - 1 through 10 (of 10 total)
  • 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.

    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.

    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.
    http://lifelight.iambaldwin.com/

    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?

    Thanks!

    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.

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

    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?

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

    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.

    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….

    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 …

    http://www.keithmillington.co.uk/wordpress/?p=22

Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘how to only show future posts in a cat’ is closed to new replies.
Skip to toolbar