Using ACF Pro 'Select' fields with Dynamic Content - How to get 'label' rather than 'value'?

Ok, so I’ve decided to checkout layouts, to see whether I can achieve most of what I want to do without the usual PHP templates, and seem to have hit a stumbling block…

I have a ‘Select’ field where I’d like to retrieve the ‘label’ rather than the ‘value’.

I’ve used both of the following with no joy (I can only get the value, which isn’t very user-friendly on the front end:
{{dc:acf:post_field_setting field="vehicle_sales_status" key="choices.value"}}

{{dc:acf:post_field field="vehicle_sale_status"}} - this returns the value, which isn’t what I want.

I’ve hunted around, and can’t see any documentation on this. I know how to do this easily enough in PHP, but want to know whether ‘layouts’ can now achieve the same?

Hello @sguilliard,

Thanks for writing in!

You may need to use the Post Field Setting: {{dc:acf:option_field_setting field="vehicle_sale_status" key="label"}}.

If this is NOT helping, provide us access to your site so that we can check your settings. Please create a secure note with the following info:
– Link to your site
– WP login URL
– WP username
– WP password
– WP Administrator Role
- Confirmation that we can access and make changes to your site

To know how to create a secure note, please check this out: How The Forum Works

Best Regards.

Hi @ruenel,

I have been using the Post Field Setting (your code shows an Option Field Setting though - for the avoidance of doubt I’ve also tried this to confirm that doesn’t work either);
{{dc:acf:post_field_setting field="vehicle_sale_status" key="label"}}

This just returns the field label, rather than the label of the option selected:

So what I actually get is the ‘values’ rather than the labels of the options selected:

Rather than the Choice value, I want the Choice Label i.e. ‘Coming Soon’ rather than ‘coming_soon’, or ‘For Sale’ rather than ‘for_sale’

1 Like

It’s ok, at some point during my experimentation I had change the select field output from ‘Both (Array)’ which meant I couldn’t get both values anymore.

The DC string that I thought should work, now does:
{{dc:acf:post_field_setting field="vehicle_sale_status" key="value.label"}}

Sorry to have bothered you with my schoolboy error! D’oh!

We’re glad you sorted it out.

Cheers!

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.