Hi,
Rather than show a DOB from an ACF datepicker, id like to show the calculated age instead, is there a way to do that in conerstone?
Ta,
Hi,
Rather than show a DOB from an ACF datepicker, id like to show the calculated age instead, is there a way to do that in conerstone?
Ta,
Hello @MaximShield,
Thanks for writing to us.
Regretfully there is no option for that at the moment. It would require custom development I would suggest you please contact a developer who can assist you with your concerns or you can subscribe to One where customization questions are answered. Please note we don’t provide custom development support. It is out of the support scope.
Thanks for understanding
No worries, I did figure it out if anyone is interested tho…
I added a php snippet shortcode plugin then created this snippet…
<?php
$date = get_field('date_of_birth');
$birthday = new DateTime($date);
$interval = $birthday->diff(new DateTime);
echo $interval->y.' years old';
?>
Then added the shortcode to the text box (inside the loop of the post type). In this case on a cpt layout page.
Just make sure the ACF custom date field is called ‘date_of_birth’ or matches whatever you want.
I also used this to add a ‘years on the team’ field. Just took out the ‘years old’ bit and changed the field name.
Maybe that would be a good feature request, a kind of in-built php snippet tool? I’m sure its possible with the looper but i couldn’t do it!!
Bon courage,
Tatty bye.
This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.