Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save tomfinitely/e93b2c3eff30e0ee94d3ded11fec00d9 to your computer and use it in GitHub Desktop.
Save tomfinitely/e93b2c3eff30e0ee94d3ded11fec00d9 to your computer and use it in GitHub Desktop.
WordPress Advanced Custom Field (ACF) - Conditional Checkboxes with Labels as Output (with option of Values as URLs)
//* Program Locations
$program_locations = get_field( 'program_locations' );
if ( $program_locations ) {
echo '<section class="location-widget widget widget_text"><div class="wrap widget-wrap">';
echo '<h4 class="widget-title widgettitle">Program Locations</h4>';
$field = get_field_object('program_locations');
$value = $field['value'];
$choices = $field['choices'];
echo '<ul>';
/*
foreach ($field['value'] as $value => $label) {
echo '<li><a href="' . $label . '" class="icon-angle-right">' . $choices[ $label ] . '</a></li>';
}
*/
foreach ($field['value'] as $value => $label) {
echo '<li>' . $choices[ $label ] . '</li>';
}
echo '</ul></div></section>';
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment