Skip Navigation

[Resolved] Connect two posts without form relationship

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

Sun Mon Tue Wed Thu Fri Sat
- 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Kolkata (GMT+05:30)

This topic contains 3 replies, has 3 voices.

Last updated by Minesh 2 years, 11 months ago.

Assisted by: Minesh.

Author
Posts
#2268373

Tell us what you are trying to do?

I have a view loop of post A, and i want to create a link that once pressed will connect this post A to a specific post B (I have post B ID passed by URL). I have also created relastionship between post A and B.

#2268515

Nigel
Supporter

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

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

If you want to connect two posts on the front end without using a relationship form then it would be a wholly custom implementation.

Your link would trigger some JS that used ajax (or maybe a custom REST API endpoint) to trigger code on the server which then used the relationships API (specifically, toolset_connect_posts: https://toolset.com/documentation/customizing-sites-using-php/post-relationships-api/#toolset_connect_posts) to connect the posts.

Probably easier to include a relationship form directly in the output of your View and pre-populate and hide the post selectors so that you just show a button to connect posts.

#2268689

So it's possible to pre-populate a form relationship of parent and child? I have read that it's possible only once! Please let me know how to do this.

Best regards

#2269005

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

If you are using post relationship form then it offers the attribute parent_item and child_item using which you can pre-populate the parent and child item within the post relationship form.

For example:

[cred-relationship-form form='your-form' parent_item='999' child_item='111']

You will require to pass correct parent and child IDs to parent_item and child_item respectively.