In my set-up, there are two Custom Posts called Book
s and Chapter
s.
For Chapter
s, 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 Chapter
s.
I can get the Book
when I have an instance of Chapter
. What I need is getting the all Chapter
s 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! 🙂