In my set-up, there are two Custom Posts called Books and Chapters.
For Chapters, I have created a Custom Field called CF_Book, which is a “Post Object”, and links to that particular Chapter‘s Book.
There is a one-to-many relationship (From Book‘s point of view.): One Book has many Chapters.
I can get the Book when I have an instance of Chapter. What I need is getting the all Chapters when I have an instance of a Book. How do I do that?
Hello…
Since you have the Book, you can get the Book ID, then you can query all chapters where CF_Book = Book ID
Here’s a resource to help with Querying posts with Custom Fields.
Let me know if that’s helpful for you!
Thanks Keith, this worked! 🙂