lundi 8 janvier 2018

Accessing all Advanced Custom Field checkbox values

Is it possible to access all values for an ACF Checkbox field available in the ‘Choices’ field settings?

enter image description here

These values are being used to populate a filter dropdown, so therefore simply associating these values with a singular $post leads to inconsistent results. i.e. my current approach only works when there are posts associated with the custom field to populate the dropdown:

$courses_fieldObj = get_field_object('course_check');

$courses = $courses_fieldObj['choices'];
foreach ($courses as $value => $label): ?>

The ‘options’ argument looked promising, however, this doesn’t seem to make available the ‘Choices’ values.

Solutions outside of ACF’s api (such as WPDB queries suggested here) also look promising, however, since ACF stores these vals in a serialised array, I am hoping for a simpler solution.

Many thanks in advance!




Aucun commentaire:

Enregistrer un commentaire