I am trying to create and link custom post with relationships, all created with Tooset, by php. The creation of the custom post is done correctly but, when creating the links, I get the error "Call to undefined function toolset_connect_posts()".
I'm running all of this through the Code Snippets plugin in run once mode.
Any idea why it doesn't recognize the toolset_connect_posts function?
I have managed to use the toolset_connect_posts function by running the code after all the plugins have been loaded. Now, I get the following error: "Uncaught InvalidArgumentException: The element to connect with doesn't belong to the relationship definition provided"
I am trying to link a custom post of type, called comarca, with a custom type, called municipio, through a relationship named 'comarca-municipio' (1:N) with the following code:
It looks like you simply have the arguments in the wrong order (the error indicates that the values of either—or both—of $municipio_id or $comarca_id don't correspond to the expected post types for the parent and child posts in the relationship).