[Resolved] How to set the parent in a CRED form for child posts on the same page
This thread is resolved. Here is a description of the problem and solution.
Problem:
Client has a CRED form to publish child posts, and wants to include the form itself on the parent page. In that case how to set the parent post id in the CRED form?
Solution:
Use the wpv-post-id shortcode for the field value, like so:
[cred_field field='_wpcf_belongs_party_id' value='[wpv-post-id]' select_text='--- not set ---' class='form-control' output='bootstrap' ]
This support ticket is created 6 years, 11 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.
I'm not sure if I'm just being stupid, but I can't seem to find this info anywhere.
I'm trying to create a CRED form for a child post type. But I want to display the form on the parent post.
In other words, I have a parent post type called Parties. On the single page for parties I want to include a CRED form for a child post type called Quotes. I have done this, but when I save the form it does not save the parent details. I'm not sure how to tell it to save the parent ID as the parent post above the form.
I haven't tested this, but if you are displaying the child form directly on the parent post, then you should be able to use the wpv-post-id (which will be the id of the current post, i.e. the parent) in your child post CRED form as the value for the parent post selector.
Your child form must include the field for the parent post id (even if you hide it with CSS), so try setting the value with wpv-post-id.
Let me know how you get on, if it doesn't work I'll have a re-think.
Sorry, you need the square brackets around the shortcode, I didn't have it in my original reply because of formatting limitations, but it would be like so:
[cred_field field='_wpcf_belongs_party_id' value='[wpv-post-id]' select_text='--- not set ---' class='form-control' output='bootstrap' ]
If that doesn't work I will need to think of something else.