Hi,
I fully understand that PHP custom code isn’t covered by Theme.co support, but since the issue is similar when using TWIG, I hope you can guide me on how to resolve it in any of these ways.
I have a Custom Post Type “Specialist” with a number of fields. There are two date fields used one to dynamically calculate a person’s current age and the second for years of experience. When I integrate a PHP function or TWIG template to accomplish this, I encounter an unusual issue. Some of the values in the array are processed and calculated properly, but others return an error. I’ve been trying to change date format but none of them worked out. Currently, ‘d/m/Y’ format is used everyware (Word Press defaults for the date format as well as respective ACF fields). What am I doing wrong?
I will provide details on the implementation for TWIG as it is an officially supported feature.
{% set birth_date = acf.post_field({"field":"specialist_birthdate"}) %}
{% set difference = date(endDate).diff(date(birth_date)) %}
{% set age = difference.y %}
{{ age }}
The code for years of experience is almost the same. Here is what I get for some of the records on the front-end (if PHP function is used I get blank page for the specialist where an error persist):
And here what I get inside Cornerstone:
Here is the link to the specialists archive page for preliminary check of some more examples.