Skip Navigation

[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, 2 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.

Sun Mon Tue Wed Thu Fri Sat
- 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 -
- 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 -

Supporter timezone: Europe/London (GMT+00:00)

This topic contains 4 replies, has 2 voices.

Last updated by gavinS-2 6 years, 2 months ago.

Assisted by: Nigel.

Author
Posts
#605109

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.

#605140

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+00:00)

Hi Gavin

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.

#605352

Hi Nigel

Thanks for the help, but this doesn't seem to have worked. I'm assuming you mean I should do this in the CRED form:

<div class="form-group ">
		<label>party Parent</label>
		[cred_field field='_wpcf_belongs_party_id' value='wpv-post-id' select_text='--- not set ---' class='form-control' output='bootstrap' ]
	</div>

However when I go in to the Quote post in the backend in the post relationship box it says:

This Quote belongs to Party [Search for Parties]

which I'm assuming means the relationship has not been set?

#605372

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+00:00)

Hi Gavin

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.

Let me know.

#605379

Ah silly me. That's it. Thank you sir.

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