• Resolved webskitter

    (@webskitter)


    Hi,

    I Have a pod called events with some events as posts. Now each event has an enddate field in it. How can I filter list pods items on the enddate field. So when current date passed enddate field, this event doesn’t appear in frontend anymore.

Viewing 5 replies - 1 through 5 (of 5 total)
  • Marcel

    (@mgringo)

    This is exactly the Question I have. Anybody???

    Plugin Contributor Jim True

    (@jimtrue)

    You’re talking about front-end display, so it really depends on how you’re displaying them.

    If you just want to do it in a shortcode, you’d need to use date comparison with current date in a where clause.

    From our Shortcode and Find documentation:

    your where clause would look something like this:

    where="CAST(enddate.meta_value as DATE) BETWEEN CURDATE() and '2020/01/01')"

    Dates are stored in the post meta table as yyyy-mm-dd hh:mm:ss so you need to cast the value as DATE in order to do Date math on them. BETWEEN is the better operator here because it includes an end date, in case you don’t want to show everything past the current year.

    If you’re displaying in another method, please let us know how you’re doing that and we’ll add the method in this forum post. WP Query would end up using the meta key syntax methods.

    Thread Starter webskitter

    (@webskitter)

    Tnx for your answer Jim,

    Here is my output frontend of date field as ‘d F Y’ so like 20 December 2018

    And I’m doing this in a shortcode

    • This reply was modified 6 years ago by webskitter.
    Thread Starter webskitter

    (@webskitter)

    Hi Jim

    Got it … works now … Thanks!!!

    Plugin Contributor Jim True

    (@jimtrue)

    Awesome, glad to hear it!

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘unpublish when date field expired’ is closed to new replies.