Tell us what you are trying to do?
I want to create relationships but not based on the post_id (automatically created by WordPress) but based on a field.
I've imported 2 tables as custom post types and they have unique ID's and Foreign keys.
I want to relate them by these ID's instead of the Toolset automatic relationship.
I hope you understand what I mean.
Kind regards, Bas
I've imported 2 tables as custom post types and they have unique ID's and Foreign keys.
Toolset's new post relationship system uses post IDs to establish connections between posts. Are the IDs you mentioned stored in some other table, or as some key other than ID in the post table? If so, it's not possible to use those IDs directly as criteria in Toolset's new post relationships system. The new post relationships system isn't designed to relate posts in any way other than by post ID.
Can you explain why you want to use these other unique IDs? If I understand the problem, I might be able to offer a different solution that works in the current system. Please let me know.
Hi Christian,
Thanks for the support. I have 3 already created tables (from an old Mysql / PHP website) which I wanna use for creation of custom post types.
The first table is called: Seasons
* SeasonID
* Season
* Description
The second table is called: Recitals
* RecitalID
* SeasonID
* ArtistID
* Date
* Description
And the third table is called: Artists
* ArtistID
* Name
* Description
I hope you can see my problem. I want to connect the tables with their ID's and foreign keys.
They are already defined in the tables. I want to import the tables as they are.
Thanks again for your help.
I can send you the CSV files if you would like to test.
REgards, BAs
I want to import the tables as they are.
Okay thanks. Based on your description, it sounds like you want to import some custom posts and their existing relationships. That's certainly possible. However, if the tables you are referring to are literal database tables, this isn't how to approach the import process. WordPress stores all posts, including all custom post types, in the same database table. So all posts from an external source must be imported into the same, standard posts table. Custom fields for all post types are stored in the same postmeta table. Toolset's post relationship references are not stored in either the posts table or the postmeta table, they are stored in custom Toolset relationship tables. Related posts are linked using post ID references and relationship ID references. So the database table structure you described isn't applicable for WordPress or Toolset.
Based on the information you provided, it sounds like you have 3 custom post types and two post relationships:
Post Relationship 1: One-to-Many relationship between Recitals (parent) and Seasons (child)
Post Relationship 2: One-to-Many relationship between Recitals (parent) and Artists (child)
You can import posts and their predefined relationships into Toolset using a CSV file. Here's an overview of CSV imports:
https://toolset.com/documentation/user-guides/how-to-import-content-into-wordpress-using-csv/
Here's some more specific information about importing post relationships:
https://toolset.com/documentation/user-guides/importing-content-from-csv-with-post-relationships/
We also offer a PHP API that will allow you to connect existing posts programmatically:
https://toolset.com/documentation/customizing-sites-using-php/post-relationships-api/#toolset_connect_posts
I hope this information helps you understand how to proceed importing existing content and post relationships into the Toolset system.
I'm going to try it another way but thanks.