Hi,
I created a custom field and I want him to dynamically fill the publish post date when I publish a post.
Example :
If I publish a post today, I want when the action of publishing is done to find 30/09/2020 in my custom field
If I schedule my post for tomorrow then I want to find tomorrow 01/10/2020 in my custom field.
Same idea if I publish my article at an earlier date.
I already tried this :
add_action('acf/save_post', 'my_acf_save_post');
function my_acf_save_post( $post_id ) {
$value = get_the_date();
update_field('name_of_my_custom_field', $value, $post_id);
}
But I always get today’s date and not the real published date.
One other thing, I don’t want my custom field to update when I will update my post in the future. So I thought about a condition like : IF my custom field is not empty THEN i do nothing but I am not able to do it.
Any ideas ?
Thanks by advance and sorry for my poor english.