Loop with custom posts, to include information from different custom post type

With 2 separate post types, basically, you need to run two queries. Where and how depends on what the real data look like. For example, you could run query 1 to get info on all universities, and query 2 to get the specific courses you want to show. Then loop through query 2, output its information, and using the schoolID identify the university within the query 1 data and output that. The risk is if you have info on a whole lot of universities, you’re querying to get info on every single one every single time.

Or, you could run query 1 to get the specific courses you want to show, if there aren’t very many at a time. Loop through that query outputting the course information, and inside that loop, run query 2 to get only the specific university you need, and output its information. The downside here is, you are always running multiple queries, so if you have say 5 courses from 1 university, you are still querying to get that university’s information 5 separate times.

A third and possibly more performant option: run query 1 to get the specific courses you want to show, including your schoolIDs. Then run query 2 to get only the universities with those specific schoolIDs. Then, similar to the first option, you can loop through the courses, and the trick is figuring out how to identify which university matches.