Support

Account

Home Forums Backend Issues (wp-admin) Phone field with href="tel:" link Reply To: Phone field with href="tel:" link

  • $app_phone_number = get_field(‘xxx’);
    $code = ‘+48’

    <?php
    if ( (strpos($app_phone_number, $code) !== false) && strlen($app_phone_number) > 11 ) {
    $country_code = substr($app_phone_number, 3);
    } else {
    $country_code = $app_phone_number;
    }
    $tel_link = preg_replace('/[^0-9]/', '', $app_phone_number);
    ?>
    
    <a href="tel:+<?php echo $tel_link; ?>"><?php echo $country_code; ?></a>