I have two channels, Courses and Instructors. In Courses I'd like to have a an entries field called "Instructor" so that this will display on the courses page.

I can't seem to figure out how to do this. I have found a few tutes but nothing I have tried has worked. Whats the best way of doing this?


Everything you need to know is in the Relations part of the official documentation.

You essentially want to add an Entries field to your Courses channel and then when you set it up pick Instructors as the source. If you only want to pick one instructor, just set the limit to 1. How you then use this in the templates can be found here.

  • So I've tried using the code {% for entry in entry.instructor %} ... {% endfor %} but all I get is a 500 Fatal error. I was using the documentation before but as I mentioned above I can't seem to figure out the precise code that would get it to work and the documentation has so much assumed knowledge that I can't figure it out. – JeffTalbot Jun 11 '15 at 0:34
  • I've tried many other variations like {% for instructors in courses.instructor %} ... {% endfor %} but none seem to work. To me that code is exactly like the example {% for ingredient in cocktail.ingredients %} <li>{{ ingredient.getLink() }}</li> {% endfor %} but it doesn't work and I really don't understand why... – JeffTalbot Jun 11 '15 at 0:45
  • 1
    So the winner is {% for instructors in entry.instructor %} I found that also there was come other code from when the instructor field was just a text field that was causing issues. Thanks for the help. – JeffTalbot Jun 11 '15 at 0:54
  • Glad you got it sorted in the end. It's because you can have one or many in your relationship so an array is returned. I don't know how many instructors you are assigning to each course, but if there was only ever one you could use {% set instructor = entry.instructor.first() %} which would bring you back just the one, or null (I think) if you haven't yet assigned one. – Steve Holland Jun 11 '15 at 8:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.