• Hi,

    I would like to loop through nested acf relationships.

    I’ve seen this topic, but it’s closed so I’m reoppening the issue.

    The idea is to go from post A to post B to post C or more rigourrously form post A to its related posts B.x, and from each posts B.x to their related posts C.x

    I have created two meta-shortcode MSH1 and MSH2

    MSH1
    is on post A, and basically get the id of the related posts of A, and pass it for MSH2 like such :

    <ul>
      [related AtoB]
          [field id]
          [pass field=id]
            [if field=id id={FIELD} empty=false]
             <li>[MSH2 passedid='{FIELD}']</li>
            [/if]
          [/pass]
    [/related]
    </ul>

    MSH2 :
    get the passed value and use it in a loop like such :

    [loop id={PASSEDID}] 
         [field title]
    [/loop]  

    This is all ok, it display a list with every post B.x IDs and Titles
    However if I change MSH2 to like such

    [loop id={PASSEDID}] 
       <ul>
          [related BtoC] 
             <li> -->  [field title]</li> 
          [/related]
       </ul>
    [/loop]  

    The fist post, B.1, ID and Title are displayed, and the nested list for C.x posts is displayed with the appropriate titles
    But instead of having B.2, B.3 IDs and Title, I do have postA ID

    Do you have any other idea how to approach this issue ?
    Thank’s in advance

  • The topic ‘Nested ACF relatioship’ is closed to new replies.