Skip Navigation

[Resolved] How to automatically set the parent on a Form to publish child posts

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

Problem:
A Form publishes child posts and is shown directly on the parent post. How to set the parent automatically?

Solution:
To automatically set the parent post, you still need to include the parent field but—when the child post form is included on the parent post page—you can pre-set the value by adding the value attribute set to the current post id, something like this:

[cred_field field='@obituaries-condolences.parent' select_text='--- not set ---' class='form-control' output='bootstrap' value='[wpv-post-id]']

The parent field must be included in the form to work. When you don't want your users to see it you can hide it with CSS.

This support ticket is created 5 years, 7 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 1 reply, has 2 voices.

Last updated by Nigel 5 years, 7 months ago.

Assisted by: Nigel.

Author
Posts
#1077140
error2.png

It would be great if you can give suggestion.
1) There are two custom post type(Obituaries & Condolences)
2) I have Created a Relationship between these two post(One to Many)(i.e. Obituaries->Condolences).
3) Then I have Created one Post form and displayed at Front Side.
But at the time of displaying I am getting on extra field (Title) Which i don't want to display and Second I am Getting Select box which is displaying all Obituaries post. So Instead of that I want to Specify PostId( Means User don't need to select Obituaries Post) It should take automatically current post.

Please find an screeshot

#1077259

Nigel
Supporter

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

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

Hi Henry

Typically you create a Form and auto-generate the markup, and shortcodes for all of the fields available for the post type in question are added to the form along with various markup.

So the post title would be included. If you don't need it, you can simply delete the field for the post title (and surrounding markup) from the form. Note that in this case an auto-generated title would be created for the post (a WordPress post cannot not have a title).

To automatically set the parent post, you still need to include the parent field but—when the child post form is included on the parent post page—you can pre-set the value by adding the value attribute set to the current post id, something like this:

[cred_field field='@obituaries-condolences.parent' select_text='--- not set ---' class='form-control' output='bootstrap' value='[wpv-post-id]']

The parent field must be included in the form to work. When you don't want your users to see it you can hide it with CSS.

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