Displaying Relationships on the Frontend

Learn to display relationships on the frontend of the website by displaying related courses on an event and teacher post.

The ACF plugin gives us access to the get_field() function to get the value of the custom field. This function returns an array of post objects.

We will create a variable $relatedCourses to store the value of the custom field. This variable stores the array of Course objects.

Display related courses on event post

Open the single-event.php. We will add the code to display the related courses after the event date, time and location information. Using the get_field_ function, fetch the value of the related_courses custom field as follows:

Get hands-on with 1400+ tech skills courses.