Skip Navigation

[Resolved] Using two custom fields entries in same paragraph

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Karachi (GMT+05:00)

This topic contains 5 replies, has 2 voices.

Last updated by JacquesF783 1 year, 1 month ago.

Assisted by: Waqar.

Author
Posts
#2577397

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

#2577467

Waqar
Supporter

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

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

#2577511

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

#2577543

Waqar
Supporter

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

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]

#2577619

Awesom Waqar,

Thanks a lot,

Jacques

#2577621

My issue is resolved now. Thank you!

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.