# ACF - How to do a foreach loop on pinegrow

**URL:** <https://forum.pinegrow.com/t/acf-how-to-do-a-foreach-loop-on-pinegrow/844>\
**Category:** Pinegrow WP\
**Created:** [April 10, 2017, 5:38am UTC](https://forum.pinegrow.com/t/acf-how-to-do-a-foreach-loop-on-pinegrow/844 "2017-04-10T05:38:49Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![inovu](https://avatars.discourse-cdn.com/v4/letter/i/a9a28c/32.png) [@inovu](https://forum.pinegrow.com/u/inovu)\
**Post date:** [April 10, 2017, 5:38am UTC](https://forum.pinegrow.com/t/acf-how-to-do-a-foreach-loop-on-pinegrow/844/1 "2017-04-10T05:38:49Z")

</div>

Hi,

I´m displaying some fields from ACF, and I got into a problem  
I need to display this:

```
<?php // lugar_de_atencion ( value )
$lugar_de_atencion_array = get_field( 'lugar_de_atencion' );
if ( $lugar_de_atencion_array ):
	foreach ( $lugar_de_atencion_array as $lugar_de_atencion_item ):
	 	echo $lugar_de_atencion_item;
	endforeach;
endif; ?>

```

Well… what I did was, to create a div, and instead of adding a custom PHP code (like I do for single elemens display) I just right-click on the div, and do “Edit Code”, and inserted the PHP code.

It worked… but I wanna know if there is any proper way to do it, to insert a code like that, so I can format it adding paragraphs and h1, and other stuff inside the foreach, and properly see it in the pinegrow tree?

Please, If you take a look at the screenshot, I can show you what I did (put the phocode doing right-click and adding it) I wanna add that I tried to add it doing the “preview php-code” but i was unable to edit it.

 ![](https://canada1.discourse-cdn.com/flex036/uploads/pinegrow/original/1X/f3a7540428d8ba986a979264a3bd1d4a50700bbd.png)

---

<div class="post-metadata">

**Author:** ![Terry44](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.pinegrow.com/terry44/32/175_2.png) [@Terry44](https://forum.pinegrow.com/u/Terry44)\
**Post date:** [April 11, 2017, 5:29am UTC](https://forum.pinegrow.com/t/acf-how-to-do-a-foreach-loop-on-pinegrow/844/2 "2017-04-11T05:29:08Z")

</div>

That does not look like wordpress code to me. They use loops, the loop, do loop or something instead of foreach, I have not used wordpress in years though. Sorry I couldn’t help.

I personally do not use Pinegrow to code, I use it for displaying of content, themes and css stuff. I found PG a pain for coding PHP and other behind the scenes stuff not directly related to display. How do you find the WP version for creating themes?

---

<div class="post-metadata">

**Author:** ![inovu](https://avatars.discourse-cdn.com/v4/letter/i/a9a28c/32.png) [@inovu](https://forum.pinegrow.com/u/inovu)\
**Post date:** [April 11, 2017, 8:18pm UTC](https://forum.pinegrow.com/t/acf-how-to-do-a-foreach-loop-on-pinegrow/844/3 "2017-04-11T20:18:42Z")

</div>

Hi Terry44,

That loop is what i got from ACF to display one of the fields.

About the WP version for creating themes , i don´t understand what you mean?

tx, Bruno.

---

<div class="post-metadata">

**Author:** ![Terry44](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.pinegrow.com/terry44/32/175_2.png) [@Terry44](https://forum.pinegrow.com/u/Terry44)\
**Post date:** [July 23, 2017, 12:50am UTC](https://forum.pinegrow.com/t/acf-how-to-do-a-foreach-loop-on-pinegrow/844/4 "2017-07-23T00:50:22Z")

</div>

You seem to be using Pinegrow to create Wordpress Themes. I personally do not do this. I was curious how your experience was using Pinegrow as a Wordpress Theme designer.

---

<div class="post-metadata">

**Author:** ![Emmanuel](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.pinegrow.com/emmanuel/32/6294_2.png) [@Emmanuel](https://forum.pinegrow.com/u/Emmanuel)\
**Post date:** [July 23, 2017, 8:15am UTC](https://forum.pinegrow.com/t/acf-how-to-do-a-foreach-loop-on-pinegrow/844/5 "2017-07-23T08:15:53Z")

</div>

Please, have a look at this:  
[http://docs.pinegrow.com/how-to-use-acf-pro-flexible-content-with-pinegrow-wp/](http://docs.pinegrow.com/how-to-use-acf-pro-flexible-content-with-pinegrow-wp/)

Best regards.
