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.
Viewing 15 topics - 676 through 690 (of 711 total)
Problem:
Showing Other Child Posts on a Child Post Page using view OR
Display all other Teacher Posts (child) of the same Teacher (parent) which the current child Teacher Posts belongs to
Solution:
You should filter your view by post relationship with shortcode attribute and pass your parent Id as value to shortcode attribute to display the related child post.
Problem: I am using ACF relationship fields to create links between two custom post types - Practices and Events. The Events CPT contains a Repeating Field Group (RFG) from Types. One of the fields in that RFG is a custom date field. On the Practice Area single post, I would like to display all the RFGs that occur on or after today, and also belong to an Event related to the current Practice Area post in the ACF relationship.
Solution: Use custom code to determine the IDs of the Event posts that are related to the current Practice Area. Not sure how that works, so consult the ACF documentation.
RFGs are essentially children in a parent/child relationship with the post where they are saved. Use the toolset_get_related_posts API to determine which RFG post IDs are associated with those Event IDs, and push those RFG IDs into an array. Pass those IDs into a View of RFG's post ID filter using render_view. Add a custom field date filter to the View of RFGs by date in addition to post ID. If no related RFG IDs are found, do not render the View.
Problem: I would like to create a View of posts in a M2M relationship, and I would like to sort the View by a custom field stored on the intermediary post type.
Solution: It is not possible to sort a View of one post type by a custom field applied to another post type. Instead, you can make the intermediary post type visible in wp-admin and create a View of the intermediary post type sorted by the custom field. In the Loop of the View, you can output information about the related posts using Views shortcodes.
Problem: I would like to be able to get the ids of both related posts in a M2M relationship using the PHP Post Relationships API, when the intermediary post ID is known.
Solution: Use the toolset_get_related_posts API to retrieve related post information using the intermediary ID like this: