Skip to content

Instantly share code, notes, and snippets.

@Spirecool
Created April 3, 2021 12:43
Show Gist options
  • Save Spirecool/2052efc458d4f4a237e6c2d0f9ca99b7 to your computer and use it in GitHub Desktop.
Save Spirecool/2052efc458d4f4a237e6c2d0f9ca99b7 to your computer and use it in GitHub Desktop.
//Code to display ACF checkboxes as list
add_shortcode('acfBr', 'brListFunction');
function brListFunction($atts, $content) {
extract(shortcode_atts(array("id"=>'','field'=>''),$atts));
if($field){
if($id=''){
global $post;
$id=$post->ID;
}
$content=get_field($field,$id);
return implode('<br>',$content);
}
return '';
}
//Then use the short code format to display the appropriate value:
[acfBr field="FIELD_NAME"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment