Home  >  Q&A  >  body text

ACF true/false field returns yes/no instead of 1/0

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粉262113569P粉262113569378 days ago522

reply all(1)I'll reply

  • P粉530519234

    P粉5305192342023-09-11 00:23:32

    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'.

    reply
    0
  • Cancelreply