Displaying Reverse Relationship
Learn to display the reverse relationship by displaying the related events in the course post.
We'll cover the following...
The related_courses
custom field displayed on the event and teacher posts links the course post type with the event and teacher post types. When creating an event or teacher post, we can choose the related courses. In the previous lesson, we saw how to display the relationship on the event and teacher posts.
In this lesson, we will focus on displaying the reverse relationship, i.e., displaying the events and teachers on a course post. This is not as straightforward as displaying the simple forward facing relationship.
The custom field which links the course and event post types is associated with the event post type. So how do we get the information of that custom field in the course post type? The answer lies in custom queries.
Custom query to get related teachers
The related_courses
custom field can be accessed on a teacher post using the get_field()
function to displays the courses taught by a ...