• Resolved andrewsavikas

    (@andrewsavikas)


    Hello,

    I am using Advanced Custom Fields 5, and I have a Repeater field to hold external reviews related to a custom page type. The field is called “external_reviews”, and there are 4 sub fields within it. I would like to iterate over each of the sub-fields, but am struggling to do so using either the array or loop commands.

    I am able to use this shortcode:

    [array external_reviews debug=true]
    [/array]

    Which results in this output:

    Array
    (
        [0] => Array
            (
                [review_url] => http://example.com
                [site_name] => Example Review Site
                [review_snippet] => I love this product!
                [reviewer_name] => John Smith
            )
    
        [1] => Array
            (
                [review_url] => http://foo.com
                [site_name] => Another Review Site
                [review_snippet] => Hello World!
                [reviewer_name] => Jane Doe
            )
    
    )

    However, I am not sure how to then descend into the child arrays to access their values.

    In pseudocode, what I am trying to do is:

    for each review in external_reviews
      echo site_name
      echo review_url

    Thank you.

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)

The topic ‘Looping through nested arrays’ is closed to new replies.