0
votes

I made a repeater field in my option pages using ACF but i can't get the value inside it :

_basefooter.twig

{% for item in options.get_field('footer_link') %}
    <a href="{{item.link}}">{{item.link_title}}</a>
{% endfor %}

{{ dump(options) }}

array(1) {
  ["footer_link"]=>
  array(2) {
    [0]=>
    array(2) {
      ["link_title"]=>
      string(17) "Mentions légales"
      ["link"]=>
      string(38) "//localhost:3000/mentions-legales"
    }
    [1]=>
    array(2) {
      ["link_title"]=>
      string(29) "Politique de confidentialité"
      ["link"]=>
      string(50) "//localhost:3000/politique-de-confidentialite"
    }
  }
}

Anyone knows where is the problem ?

1

1 Answers

0
votes

It seems to me that the issue you are experiencing is due to the fact that you have multiple arrays nested inside of each other. footer_link is an array which contains arrays inside of it, so you need to do a double for loop to get the data you are looking for. Trying something like this:

{% for item in options.get_field('footer_link') %}
  {% for link in item %}
    <a href="{{link.link}}">{{link.link_title}}</a>
  {% endfor %}
{% endfor %}

I hope that helps.