I have created a many-to-many relationship between two post types, 'Housing Developments' and 'Posts'. I haven't created an intermediary post type. (The relationship slug is 'housing-development-post'.)
When I edit a Housing Development and try to connect it to an existing post, the modal dialog Connect Existing Post shows me the titles of a completely different post type ('Offices'), rather than the posts I want - so there's no way of setting the connection correctly.
If I try creating a new post, instead of connecting an existing one, I see the message "A new Post has been connected to this Housing Development", but it doesn't create a standard Post, it creates a custom post of post type 'office'.
I took a look at the wp_toolset_relationships table in the database, and I can see a row for the relationship, but the 'child_types' field appears to be set wrongly there - it doesn't match 'set_id' in the 'wp_toolset_type_sets' table which is assume it should.
In addition, once the new post has been created, it appears in the list, with the usual action links appearing below it. However when I click on 'Edit' this simply takes me back to editing the parent Housing Development (ie the Edit link contains the post id of the parent post, rather than the id of the newly created post). Note that the 'Office' post type is created by another plugin, and it isn't editable through the normal interface, so perhaps that's causing the latter issue.
I'd be grateful if you could take a look at what's going on here.
Many thanks,
Chris
Hi, I can see that no intermediary post type exists here:
lien caché
Is it possible the intermediary post type was deleted? It shouldn't be possible to finalize a m2m relationship without an intermediary post type. Regardless, it's probably best at this point to delete the entire relationship and recreate it.
Please try this first, then we can run some other troubleshooting steps if you continue to experience this problem with a new relationship.
Hi Christian,
Yes, you're right, there was no intermediary post type. I didn't delete it though: the wizard actually gives a checkbox to select whether or not to create one, so I assumed it wasn't required (on the "Names" screen). If it is required for many-to-many relationships, then that checkbox needs to be disabled.
Anyhow, I have deleted the relationship and recreated it, this time with the intermediary post type (and I've selected the option to show that in the admin menu). However the problem remains the same - the relationship is being created with the wrong post type.
Could you take another look?
Many thanks,
Chris
I'm a bit confused because I'm not sure where this "Offices" post type is coming from. It could be a post type created by another plugin or the theme, which is causing a conflict. As a test, please deactivate all plugins except Types and activate a default theme like Twenty Seventeen. Then try to connect a Post to a Housing Development like before. Are the correct posts shown in the search menu now?
Yes, that's right, "offices" is a custom post type created by another plugin (called "Property Hive").
OK, I've deactivate all the other plugins and switched to Twenty Seventeen. Now, on the relationships page, I see a warning "office post type does not exist or is currently inactive", which is correct of course (see screenshot).
I then deleted that relationship and tried creating a new one, and it's working correctly: the relationship is created between Housing Developments and standard Posts, and I can connect Housing Developments to Posts in the expected way.
I then tried reactivating the Property Hive plugin, and the relationship continues to work correctly, which suggests that the problem is happening when the relationship is created.
I then tried to create a new relationship with Property Hive enabled, and I think I see where the problem lies (see second screenshot). The lists of post types actually show two different post types called "Posts", and I had been choosing the wrong one! If I select the first "Posts" the relationship works correctly.
So, the problem isn't with Types, but with the Property Hive plugin: when that's registering the "office" post type, it isn't setting the labels correctly and so the default of "Posts" is used. I'll report that as a bug to the author of that plugin.
Apologies for my confusion, and thanks for you help in getting to the bottom of this!
Best wishes,
Chris