i would like to show an acf field in the loop-markup.php
When i use something like the following code in the content div, the new div is not shown an the field appears outside the grid item (screenshot attached)
$markup .= '<div class="test">';
$markup .= the_field('alter');
$markup .= '</div>';
What should i do to put an acf field as php code inside the content div?
thanks for your help. Now i get the „Warning: Array to string conversion“. The ACF Field is a choice Field. How can i get the selected Value instead of the whole array?
Hello,
i would like to show an acf field in the loop-markup.php
When i use something like the following code in the content div, the new div is not shown an the field appears outside the grid item (screenshot attached)
$markup .= '<div class="test">';
$markup .= the_field('alter');
$markup .= '</div>';
What should i do to put an acf field as php code inside the content div?
Thanks for your suppourt
Attached files: Bildschirmfoto 2025-07-13 um 12.49.50.png
Hi Iyad,
Thank you for writing to us.
This is happening because the the_field() function in ACF immediately prints the value to the page.
To fix this, you need to use get_field() instead, which returns the value so you can add it to your markup variable correctly.
Please replace your code with this:
Hope this does the trick!
Best wishes,
Salient Support
Hello Noah,
thanks for your help. Now i get the „Warning: Array to string conversion“. The ACF Field is a choice Field. How can i get the selected Value instead of the whole array?
it works fine now for text fields
Best Regards
Hey Again,
Thanks for reaching out! .
The Post Loop Builder already has a Custom Field feature that you can use . See screenshot:
Best,
Salient Support Team