Support

Account

Home Forums General Issues How to get checkbox value from custom field?

Solving

How to get checkbox value from custom field?

  • I’ve created a custom field for pages, where you can check if a certain section (another custom post type) will be displayed.

    How do I check if a checkbox (or multiple) are checked?

    If I do this I get an array:

    $show_sections_on_page = get_field('show_sections_on_page');

    Now, is my only option to manually iterate through the list every time I need to check for a certain value, or am I missing some other obvious way to go about something like this?

  • checkboxes store arrays. Yes, you need to check the array to see if it holds your value. If you want to check to see if the array contains a specific value http://php.net/manual/en/function.in-array.php

  • Thanks John, yeah just iterated the bugger. Was just wondering whether I’d be missing some obvious fancy way of getting the values.

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

The topic ‘How to get checkbox value from custom field?’ is closed to new replies.