Skip Navigation

[Resolved] Display parent on Child Form

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

Problem:
We are creating Child Posts with a Toolset Form and want to display the parent posts data (title) when we show the form on the front end so we can display a message like below:

You are entering data for .

Solution:
You can use different solutions but none is a native solution.
You can use either the deprecated - but still working for one to many relationships) ShortCodes as below:

[cred-post-parent get='title'] //Title of parent 
[cred-post-parent get='url'] //URL of parent

OR, you can nest ShortCodes, which is also something that may stop working at some point in future, as WordPress does not like nested shortcodes - however it should proceed to work in Toolset Forms and Views as long the block editor is not used:
https://toolset.com/forums/topic/past-parent-post-title-to-cred-form/
https://toolset.com/forums/topic/displaying-data-from-parent-post-type-in-cred-form/

Another approach could be to create a custom code with the above principles and output the title, so no nesting is necessary.

This support ticket is created 4 years, 10 months 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.

Our next available supporter will start replying to tickets in about 2.20 hours from now. Thank you for your understanding.

Sun Mon Tue Wed Thu Fri Sat
- - 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00
- - - - - - -

Supporter timezone: Asia/Ho_Chi_Minh (GMT+07:00)

This topic contains 2 replies, has 2 voices.

Last updated by nicolaS-3 4 years, 10 months ago.

Assisted by: Beda.

Author
Posts
#1465461

Hi,
I developed a new little service site and everything works fine except one little detail: I can't display one-to-many parent on page with form. The main page shows a list of people (parents) and a link to display a form to enter data (children) for the selected person. I have read your guides about how to display parent on child pages and I tried them all, but my page has a form instead of a view listing items (that one works !). On the form page I'd simply like to see: You are entering data for <name of selected person>. Please help. Thanks
Regards
Nicolar site?

#1465791

It's not possible to display parent or child data within a Toolset Form natively.

The main problem is we don't know what the parent will be, as the new post we are about to create doesn't yet exist and has hence no parent yet.
What you can do is use the old, but not anymore documented ShortCodes for parent post in forms.
Given you use a One To Many relationships you can still use those, as you will be working with a "standard" form, not a relationship form.
In such forms creating child posts to a parent, you can use [cred-post-parent get='title'] and [cred-post-parent get='url'] shortcodes to get the related parent posts title or URL.

Another possible solution includes listening to the URL argument which is set when you lead to the "create child post" form from some parent:
https://toolset.com/forums/topic/past-parent-post-title-to-cred-form/
https://toolset.com/forums/topic/displaying-data-from-parent-post-type-in-cred-form/

These approaches should be (either of) the solution to the task.
Note, do not extensively nest ShortCodes if possible, and if you do, alternate the usage of "" and '', in this manner:

[shortcode with_attribute="[another_shortcode another_attribute='value']"]
#1468833

Thank you Beda,
I was able to show the parent id using:
[wpv-post-title id="[wpv-search-term param='parent_<my post name singular>_id']"]
Thanks !
Regards
Nicola