Home › Forums › Backend Issues (wp-admin) › Phone field with href="tel:" link › Reply To: Phone field with href="tel:" link
webicient
Hello, I’ve added your code like this:
add_filter('acf/format_value/name=ტელეფონის_ნომერი', 'convert_phone_to_link', 20, 3);
function convert_phone_to_link ($value, $post_id, $field) {
if (!$value) {
// no value
return $value;
}
// get the tel link field
$tel_link = get_field('-phone-number');
if (!$tel_link) {
// no link
return $value;
}
$value = '<a href="tel:'.$tel_link.'">'.$value.'</a>';
return $value;
}
$(#phone-button a").attr("href", function ( index, currentvalue) {
var url_format = currentvalue.replace(/(^\w+:|^)\/\//, "");
$(this).attr("href", "tel:" + url_format);
});
But it shows me a fatal error in the first line of your code.
Here: $(#phone-button a”).attr(“href”, function ( index, currentvalue)
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.