I am using a Countdown element (probably Elementor) to show a countdown for a Time stored in an ACF field in a post. The Countdown needs a full DateTime – it wont work with just a time. The time will be fixed every day for 3 posts – 9am, 10am and 11am.
So I want to use php to update the field to today’s date but keep the time as it is in each post. This could happen on page load a function could check if the date was set to today and if not update it. But the key is the time has to stay the same.
The idea is that when a post is loaded it will always show the countdown to eg. 10am no matter what day it is.
#wordpress #acf
I’ve seen plenty of code to update the entire date field but not to maintain the time element.
2
Answers
So this seems to work for a single post ID, how can I generalise out for all posts in a specific custom post type?
To generalize your code for all posts of a custom post type try the following:
It should work…