Using ACF Field as an attribute

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.

Thanks!

2 Likes

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.

How to reproduce the problem?

It works fine here in Bricks 1.9.9.

CleanShot 2024-07-21 at 1 .11.05@2x

I’m honoured to see that none other than Katakam the WP Legend himself replied!

I found the problem (I think).

The data is inside a query loop, which I did not have activated previously. It seems activating the loop makes the whole thing output correctly.

Thanks, however, for taking the time.

Appreciate it.

Blessings!

Wow! I’m feeling so dumb :wink: 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!

1 Like

Hey guys,

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.

Is it possible?

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:
image

Printed on the website:
image

However, when I try to do the same thing, in the attribute via echo field, like this:
image
(I have tried the custom field with the “acf_” prefix as well, with the same result.)

It is completely empty:

Any idea where could be the issue?