Skip Navigation

[Resolved] Specify post parent in a form

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

Problem: I would like to use Gravity Forms to create a child post, and I would like to know how to associate that child with a parent post.

Solution: To associate a parent post with a child post, you can use the update_post_meta function with the _wpcf_belongs_business_id meta key:

update_post_meta( 456, '_wpcf_belongs_business_id', 123 );

Change 456 to the child post's ID, change 123 to the parent post's ID.

Relevant Documentation: https://codex.wordpress.org/Function_Reference/update_post_meta

This support ticket is created 7 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.

No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.

Sun Mon Tue Wed Thu Fri Sat
8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 - -
13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 - -

Supporter timezone: America/New_York (GMT-04:00)

This topic contains 3 replies, has 2 voices.

Last updated by Adrian 7 years, 2 months ago.

Assisted by: Christian Cox.

Author
Posts
#570661

I am trying to create a front end submission form.
The front end submission form should create a child post for the post the user is currently visiting.

The user is visiting a post of the type business, and the user should be able to submit a review for the business.

The post type business is a parent of the post type review.

#570778

Can I do this via Gravity Forms? I'd be specifying this via a hidden field, so there is no UI needed to get all the posts and then display them

#570787

If you're using CRED to build your forms, you can follow the guide we have here to insert a link to create a child post:
https://toolset.com/documentation/user-guides/cred-forms-for-child-content/

If you'd like the form to appear on the same page as the parent post, I can offer some assistance to modify that process a bit.

If you'd like to use Gravity Forms to create a post, I'm not really sure how that will work since it's another plugin with its own system in place for creating posts. What I can tell you is that the relationship between parent and child posts in Types is defined using the meta field '_wpcf_belongs_slug_id'. After you add the child post, you must then define its parent using this meta field. For instance, let's say the parent post has an ID of 123 and the child post has an ID of 456, and the Business post type slug is 'business'. To set the parent ID of post 456, you must call update_post_meta on the child post like so:

update_post_meta( 456, '_wpcf_belongs_business_id', 123 );

Let me know if you have any questions about this and I can offer some more detailed advice.

#570789

That's the one. I'll leave this open and post my solution if that's ok