I’m looking for help to dynamically show/hide an announcement card in a query loop on a page, relative to the publish and expire date fields as defined by ACF Date Time Picker fields.
For my Announcements custom post type, each announcement is given a publish date and expire date. My goal is to only display an announcement card when the publish date {acf_datetime_publish} is >= the Current WP Date {current_wp_date} and hide the card if the Current WP Date {current_wp_date} is > the expire date {acf_datetime_expire}.
I know these settings are incorrect, but this is as far as I made it in my setup so far:
I assume there’s a way to dynamically display the card if one condition is true and hide the card if the other condition is true. Any pointers, anyone?
Thanks so much @Ferry! Your recommendation got me steered in the right direction.
I added the :Ymd to my datetime field and also had to remove the acf_ prefix from the start of the meta key. I had inappropriately copy/pasted “acf_datetime_expire” as my meta key when I only needed “datetime_expire”, in my case.
My final meta queries look like this (for anyone needing to replicate something similar):
This allows my Announcements CPT to be prewritten and automatically become visible on the publish date/time and then hide once the expiration date/time comes.