ACF true/false field returns yes/no instead of 1/0
P粉262113569
P粉262113569 2023-09-10 09:55:46
0
1
592

I am using Advanced custom fields plugin with my wordpress. The page is based on realia so I need to show for example: garage yes/no. Balcony Y/N etc.

I have used true/false field type but it always returns 1/0. I would like to receive yes/no instead (or my own defined string). I thought use true/false. I can't find any setting in ACF to set the return value. Thanks

P粉262113569
P粉262113569

reply all(1)
P粉530519234

Have you tried using the styled UI of fields? You can set text on it.

However, if you want to get the value programmatically, you can do it like this:

$text = get_field(name) ? '是' : '否'

This will create a variable with an if else statement. Returns 'Yes' if the condition is true, otherwise returns 'No'.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template