Skip Navigation

[Résolu] How to automatically set the parent on a Form to publish child posts

Ce fil est résolu. Voici une description du problème et la solution proposée.

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 Il y a 6 années et 3 mois. 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.

Aucun de nos assistants n'est disponible aujourd'hui sur le forum Jeu d'outils. Veuillez créer un ticket, et nous nous le traiterons dès notre prochaine connexion. Merci de votre compréhension.

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)

Ce sujet contient 1 réponse, a 2 voix.

Dernière mise à jour par Nigel Il y a 6 années et 3 mois.

Assisté par: Nigel.

Auteur
Publications
#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

Les langues: Anglais (English ) Espagnol (Español )

Fuseau horaire: 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.