Not sure if I’m missing something, but I’d like to use an ACF field as a data attribute value.
Intended output would be data-bv=“321” but it is only outputting the name data-bv. The div involved has a basic text element that has the same dynamic field {acf_serving_weight} and that loads in fine.
I’ve tried with the acf field as text as well as number and niether are working. I can get other dynamic fields to work fine, such as the post id, but nothing from my acf field group.
I feel like I’m missing something or just misunderstanding how this would work, but I’ve seen other people using ACF fields in this way.
I’m watching this because I’m sitting with the same issue. Attribute is showing, but attribute data is empty. I’ve even set up ACF using the value : label format. Doesn’t work.
Wow! I’m feeling so dumb I’ve been using query loop for a while, but not this time. And my dynamic data wasn’t working. After searching, I came here, and it feels like Ahhh! Thank you!
I have almost exactly the same problem and I find out that the issue is in wanting to call custom field inside loop of another custom field (repeater).
Example:
Custom field 1
Custom field 2 - repeater
– Custom field 3 inside
– Custom field 4 inside
I want to add dynamic attribute (Custom field 1) to element that is inside query loop of Custom field 2.
Okay, I have tried a few things, and this is where I am right now:
I have successfully called the Custom field 1, which is outside of the repeater, inside of the repeater query loop, by using a code block.
Code block in the builder:
Printed on the website:
However, when I try to do the same thing, in the attribute via echo field, like this:
(I have tried the custom field with the “acf_” prefix as well, with the same result.)
The problem was in the “get_field” function, specifically in the issue of Bricks not allowing any function to run in echo when it’s not specified in the filter.
So I added this thing to my functions.php of Child theme and it works!