Created
April 3, 2021 12:43
-
-
Save Spirecool/2052efc458d4f4a237e6c2d0f9ca99b7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//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