vendredi 12 février 2021

ACF/WordPress: checkbox return format based on page

I am using ACF checkbox and have it set to return format "both". I would like to display checkbox value on the frontend except if the page is woocommerce product category (then output label). I am using a shortcode in order to output the checkbox value/label in the frontend. The only problem is, that it keeps outputting "array" and not label/value as I would like it to do. Any clues on what I am missing ??

function hello_shortcode() { 
 
// Load field settings and values.
$field = get_field_object('producent');

if( !is_product_category() ) {
    $checkbox = $field['value'];
} else {
 $checkbox = $field['label'];
}

return $checkbox;


} 
// register shortcode
add_shortcode('hello', 'hello_shortcode'); 



Aucun commentaire:

Enregistrer un commentaire