Tell us what you are trying to do? Connect two different CPTs using a custom script with toolset_connect_posts.
Is there any documentation that you are following? https://toolset.com/documentation/customizing-sites-using-php/post-relationships-api/#toolset_connect_posts
What is the link to your site? Internal development
Issue:
* Two different custom post types made with Toolset Types CPT_X (parent) and CPT_Y (child).
* Relationship one-to-many (CPT_X -> CPT_Y) created with Toolset Types after the creation of CPTs and the data in these CPTs.
1. Running an import script with WP All Import and with the Toolset Types add on. No errors.
2. When WordPress action save_post_cpt_y() is called a function is executed where the current post_id of CPT_X and CPT_Y is called with toolset_connect_posts('relationship_slug', CPT_X_post_id, CPT_Y_postid)
2.1 Two rows are now created in the database table toolset_connected_elements with CPT_X_post_id and CPTY_Y_post id.
2.2 But no row is created in the table toolset_associations when using toolset_connect_posts() in the script and no relation is shown in WP admin GUI under the posts.
3. If I make the connection/relation manually in WP admin GUI a row in toolset_associations is created together with two rows in toolset_connected_elements and I can view the connection under each post in WP admin GUI.
Do I need to call another function in the script after toolset_connect_posts or clear a cache?
Hello and thank you for contacting the Toolset support.
I run a test in a clean install with the latest releases, and I wasn't able to reproduce the issue. The function has added a line to the "wp_toolset_associations" table. And I can see the link at the parent's post edit page in WP Admin. Check this screenshot, I hope it is clear to describe what I meant hidden link
To better help you with this issue, I'll need to take a closer look at the code that you are using and how it is been executed. Please provide as many details as possible. Your next reply will be private to let you share credentials safely. ** Make a database backup before sharing credentials. **
If you would like to give it a try in one of our test sites, you can log into it with the following URL hidden link
In that case, please let me know where the code is located and how do you make it execute?
My issue is resolved now. Thank you!