• Resolved s1s2

    (@s1s2)


    I have a custom post-type called “Schools” featuring an ACF relation field called “acf_people”.

    The “acf_teachers” field is designed to link to another custom post-types called “Teachers”.

    Each “Teacher” post-type has an ACF repeater field called “acf_books”.

    I want to display all books from each teacher for every school. I proceed as follows:

    [loop type=schools]
    
    School: [field title]
    
     [related acf_teachers]
      
       Teacher name: [field title]
       Favourite books:  
     
       [repeater acf_books]
        [field acf_bookname] ([field acf_bookyear])
       [/repeater]
      
     [/related]
    
    [/loop]

    This code doesn’t work. I did some tests and it seems that the [repeater] doesn’t work inside a [related].

    Before I go for a very convoluted alternative approach, am I missing something?

    Thank you

Viewing 3 replies - 1 through 3 (of 3 total)
  • You need to split that:

    1. Loop your schools and create a list with the teachers id from the related field.
    2. End the loop
    3. Pass the ID_LIST just created
    4. Loop teachers with the id={ID_LIST} and run your repeater

    • This reply was modified 4 years, 11 months ago by polarracing.
    • This reply was modified 4 years, 11 months ago by polarracing.
    Thread Starter s1s2

    (@s1s2)

    This was the convolution I was hoping to avoid. But ok, I can do that.

    Thank you!

    (once again, I had to figure out a way to remove the last comma from the composed list)

    Build your list like this:

    [if myvar]
     [set myvar][get myvar], WHATEVER[/set]
    [else]
     [set myvar]WHATEVER[/set]
    [/set]
Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘[repeater] inside [related] not working’ is closed to new replies.