Support

Account

Home Forums General Issues Get all values from checkbox

Solving

Get all values from checkbox

  • Hello.
    Is it possible to get all the values that I have put in ACF Field Groups. I don’t want to get the values from a page.
    Just all the values that I have in field group.
    Thanks

  • You need to use get_field_object(). There is an example of displaying label and values here that uses this function https://www.advancedcustomfields.com/resources/checkbox/. The function itself is described here https://www.advancedcustomfields.com/resources/get_field_object/. You may or may not need to use the field key rather than the field name depending on where you’re getting the field object and what you’re going to do with it.

  • Hello John.

    I fix it. My problem is that when I use get_field_object(‘field_name’), returns NULL.

    But when I use get_field_object(‘field_key), it works.

    I don’t know if there is an ACF issue or something wrong with my code

  • The reason that the field key works and the field name does not is that the field is probably not defined for the current “post” that is being shown, acf is looking for a field that does not exist. When you use the field key ACF does not try to look at the current post and just gets the field that you defined. This is not a bug. When a field is not already saved for a particular post you always need to use the field key. The same holds true for may ACF functions.

Viewing 4 posts - 1 through 4 (of 4 total)

The topic ‘Get all values from checkbox’ is closed to new replies.