Home › Forums › General Issues › Use Date/Time picker as post publication date › Reply To: Use Date/Time picker as post publication date
Since it is being saved as draft, do you have a pre_save_post filter that is doing this? If so, the I would change the post date there. Otherwise, you should do some testing here to make sure that you’re updating the right post since this will run on every post that’s saved.
More than likely the reason the post date is not being updated is that the value returned by ACF is not a valid date that can be inserted. What is the return format for the date field. It should be ‘Y-m-d H:i:s’. I don’t see anything else in your code that would cause the date not to be updated. You can check this by
$post = wp_update_post( $my_post );
if (is_wp_error($post)) {
echo 'WP ERROR: <pre>'; print_r($wp_error); echo '</pre>'; die;
}
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.