Hi there,
Let's say that I have two posts that are connected to each other via a parent-child relationship. Is it possible to require the parent post to be connected to a child? This is similar to a required custom field, but this would be a required *relationship*. Does that make sense?
The reason I'm asking is that I have a design that requires posts to be connected to other posts, otherwise the correct information won't appear on the website and error messages _will_ appear.
Thanks!
Saul
Hi, there's nothing built-in to require at least one relationship connection. We do offer the post relationships API, which can be used to query for related posts in a specific post relationship. I could show you how to write a custom function you can use in a simple conditional to test whether or not a specific post has any child posts. Let me know if you think a conditional-based approach will work.
Nah, I don't think I need the starter code.
I ended up attaching a function to the filter "edit_form_top" and checking the results of the post count returned by toolset_get_related_posts() or toolset_get_related_post() and printing warnings where appropriate. It still doesn't force the user to create the necessary post relationships, but it at least informs the user there will be a problem if they don't. That's good enough!
Thanks, Christian!
Saul