Skip Navigation

[Resolved] Access associations via API

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.

This topic contains 1 reply, has 2 voices.

Last updated by Waqar 1 year, 9 months ago.

Assigned support staff: Waqar.


I need a copy of the associations between posts in another app. Is there a way to directly retrieve all associations between posts via API (e.g. toolset_get_associations) instead of querying the related posts of a specific post (toolset_get_related_posts)?
If not what way would you suggest to sync the associations?
Thanks for your help!



Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

Hi Jonathan,

Thank you for contacting us and I'd be happy to assist.

I'm afraid, there is no single function available to get the information about all existing post associations, but as you noted, "toolset_get_related_posts" function can be used to get them on a per-post basis.
( ref: )

There are a couple of ways you can approach this, based on the overall structure and requirement of your app:

1. You can create a custom function to run periodically (using Cron) that loops through one of the post types in the relationship and fetch the attached posts to them and update the existing records to keep the data in sync.


2. You can use "toolset_association_created" hook ( ref: ) to attach a custom function that can send the information to your external app that a new post association has been created.

Likewise "toolset_before_association_delete" hook ( ref: ) can be used to attach a custom function that can send the information to your external app that an existing post association is going to be deleted.

I hope this helps.