I have a group of 12 checkboxes made with ACF, where each checkbox is a month:
jan : Jan / feb : Feb / mar : Mar / etc.
What i want to achieve is to display those 12 values in the frontend, with a particular CSS class if the month has been checked in the backend. Ej:
From the Checkbox documentation you can make use of a conditional like so:
$choice = get_field('months');
if( $choice && in_array('jan', $choice) ):
elseif( $choice && in_array('feb', $choice) ):
<?php endif; ?>
actually i need to ALWAYS show all 12 months in the frontend (inside a span tag), and the months that have been selected in the backend should have the class “selected”.
following the example in the docs, i’m only getting the selected months displayed in the frontend.
Thanks for the clarification.
In such a case, you will need to use the getf_field_object as opposed to get_field.
Let me know how it goes.
sorry but i cant get it to work.
Thanks for the follow up.
Kindly open a more personalised support ticket at [email protected]
Hope to hear from you soon.