Skip Navigation

[Resolved] URL with dynamic parameter – mail address field from related post

This thread is resolved. Here is a description of the problem and solution.

Problem: I would like to use a custom field from a related post to generate a dynamic link in the child post template. The Types field shortcode for this field is not returning any value.

Solution: You can use the Types field shortcode to output information from a related post using a special syntax in the "item" attribute, like this:

[types field="e-mail-adresse" output="raw" item="@contact-job.parent"][/types]

Relevant Documentation:
https://toolset.com/documentation/customizing-sites-using-php/functions/
https://toolset.com/documentation/programmer-reference/views/views-shortcodes/item-attribute/

This support ticket is created 4 years ago. There's a good chance that you are reading advice that it now obsolete.

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.

Sun Mon Tue Wed Thu Fri Sat
8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 - -
13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 - -

Supporter timezone: America/New_York (GMT-04:00)

This topic contains 2 replies, has 2 voices.

Last updated by michaelG-24 4 years ago.

Assisted by: Christian Cox.

Author
Posts
#1937897

I have a Post type template for jobs. In this template the contact person data is also shown (another post type conected with relationship).
Now I need a URL for starting a Ninja Forms form.
The URL has to look like hidden link

I found a nice post here explaining dynamic variables in URLs. With this information I created:

The first part of the URL is created, but the mail adress is empty. When using the "fields and text" block to show the mail-adress it's empty. Using a single field to show the adress I get a result.
What I'm doing wrong?

Hello, if you want to use a Types field shortcode to display a custom field from a related post, you must use the "item" attribute to specify the related post using a special syntax. Otherwise, the Types field assumes that you are trying to display a custom field from the current (Job) post. The syntax of the "item" attribute depends on the relationship you have set up, and which post type is the parent. For example, let's say the relationship slug is "contact-job" and it is a one-to-many relationship. If Contact is the parent of Job and you want to display a custom field from the Contact post inside the Job post, you can use the syntax like this:

[types field="e-mail-adresse" output="raw" item="@contact-job.parent"][/types]

Our documentation for the Types field shortcodes and API is available here:
https://toolset.com/documentation/customizing-sites-using-php/functions/

The "item" attribute is documented here:
https://toolset.com/documentation/programmer-reference/views/views-shortcodes/item-attribute/

If you need more assistance, I need to know:
- the slug of the relationship
- the type of relationship
- which post type is the "parent" and which post type is the "child"
...then I can offer some more direct guidance.

#1938269

My issue is resolved now. Thank you!