Hi @maxpeerawat
You can add the function in your themes’ functions.php file. This page should give you more idea about functions.php file: https://codex.wordpress.org/Functions_File_Explained.
I hope this helps.
// Su dorm out
function su_dorm_out(){
$values =get_field('su_facility_outdoor');
$field = get_field_object('su_facility_outdoor');
$choices = $field['choices'];
foreach ($choices as $value => $label) {
if (in_array($value, $values)) {
echo '<li><b class="correct"></b> ';
}else { echo '<li><b class="incorrect"></b>' ; }
echo $label.'</li>';
}
} add_shortcode( 'sudorm_out', 'su_dorm_out' );
How to return ? Now it’s not work for display.
Hi @maxpeerawat
I guess I have mistaken your question. I thought you are talking about the functions.php. I’m really sorry about that.
You can add the code to your theme template. The file to edit depends on where you want to show it. If you want to show it on a post, you need to add it to single.php file. This page should give you more idea about it: https://codex.wordpress.org/Templates.
If you add it on templates, you don’t need to wrap it in a function anymore.
Hope this helps.