Views is a WordPress plugin that lets you display post relationships.
In our user guides, you can find more information on how to display child posts, related posts, brother pages, fields of parents and fields of grandparents.
When you ask for help or report issues, make sure to tell us the type of the relationship you are trying to build and the structure of your data.
Problem: I have 3 custom post types. A is related with B, and A is related with C. I have a view with C information and i want to show also B info that are related to A.
Solution: Depending on the types of post relationships, you may also need a View of post type A.
- If A-C is a one-to-many (O2M) relationship and "A" is the parent, you do not need a View of A in this case.
- If A-C is a O2M relationship and "A" is the child, there can be multiple A's related to each C, so you need a View of A.
- If A-C is a M2M relationship, there can be multiple A's related to each C, so you need a View of A, regardless of which is the parent and which is the child.
Problem: I have two custom post types - Articles and Authors - connected in a many-to-many (m2m) post relationship. I have created a View of Articles posts, and in the list of Articles I would like to include information about the related Author.
Solution: Any time you want to display information from the "many" side of a post relationship, you'll need a View. Since the relationship between Articles and Authors is a many-to-many relationship, you'll need a nested View structure to display a list of Articles and the related Authors for each Article.
Nested View creation is not directly supported in the Block Editor, so you can use the legacy View editor if necessary. For the inner View, use a post relationship Query Filter configured with the Articles - Authors M2M relationship selected, showing items as related to the current post. You can place the inner View in the loop of the outer View using a wpv-view shortcode.
Problem: I have a custom post type and a repeatable field group (RFG) in that custom post type. I would like to create a list of all the custom posts and in that list show a list of the RFGs associated with that post.
Solution: This requires a nested View structure. Since it is not possible to create a nested View in Blocks, you must use the legacy Views editor. The process is outlined in another ticket.
Problem: I would like to know if it is better to include User data in User fields in the User profile, or to create a proxy post type as explained in the documentation for post relationships and custom search for Users?
Solution: There are pros and cons for each approach. If you plan to use custom search Views to search for Users based on filtering by these custom fields, or if you plan to use Repeatable Field Groups for some of these fields, or if you plan to use post relationships to connect multiple Users to the same post, a proxy post type is probably required as explained in the documentation link below.