Hello,
I need to achieve the following:
date field : "DOB " = 1997
Date field : "DOD" = 2009
In the content template I need to use them as inline elements in the same paragraph and display
1997 - 2009
Basical two spans in the same paragraph.
Is it possible?
How so?
Thanks,
Jacques
Hi Jacques,
Thank you for contacting us and I'd be happy to assist.
Yes, to show the values from the custom field in a single text line, you can use the Types Fields API shortcodes:
https://toolset.com/documentation/customizing-sites-using-php/functions/
For example, suppose the slugs of the two fields are 'dob-field-slug' and 'dod-field-slug'. The shortcodes in the text will look like this:
[types field="dob-field-slug"][/types] - [types field="dod-field-slug"][/types]
I hope this helps and please let me know if you need further assistance.
regards,
Waqar
Thanks Waqar,
That worked fine.
I have one more issue:
What was rendered was : "February 11, 1987 – March 11, 2031"
I would like to keep only the years "1987 - 2031"
Any chance of achieving this with Date field or should I pick Number instead as field?
Thanks,
Jacques
Thanks for the update and glad that it worked.
Yes, for the date type field, you can use the 'format' attribute to show the date in any date and time format:
https://toolset.com/documentation/customizing-sites-using-php/functions/#date
https://wordpress.org/documentation/article/customize-date-and-time-format/
For example, to show only the 4-digit year value, you can use the attribute format='Y':
[types field='dob-field-slug' format='Y'][/types] - [types field='dod-field-slug' format='Y'][/types]
My issue is resolved now. Thank you!