Den gode Husum har lavet et fix til telefon links via ACF felter ( fx. til en dynamisk medarbejder side )
function custom_acf_shortcode($atts) {
// Define the default attributes
$atts = shortcode_atts(
array(
'meta_field' => '', // ACF field key
'prefix' => '', // Prefix to add before the value
),
$atts,
'acf_value'
);
// Get the ACF field value
$acf_value = get_field($atts['meta_field']);
// Check if the field exists and return the value with the prefix
if ($acf_value) {
return $atts['prefix'] . $acf_value;
} else {
return ''; // Return empty if no value is found
}
}
// Register the shortcode
add_shortcode('get_acf_value', 'custom_acf_shortcode');