Home › Forums › Backend Issues (wp-admin) › Phone field with href="tel:" link › Reply To: Phone field with href="tel:" link
Good morning @brevalo,
The reason why you want the script at the end is that the page needs to load first so that the script can find what to change. If you put the script on top, then the script will execute first before the page loads and won’t find anything to change.
Exclamation marks? There are no exclamation marks in the script. You have to be careful with the quote marks ” “. Single and double quotation marks are common ‘ ‘ or ” “. Below is the script that I used for the ACF links.
<script>
(function($){
$(“.phoneButton a”).attr(“href”, function ( index, currentvalue) {
var url_format = currentvalue.replace(/(^\w+:|^)\/\//, “”);
$(this).attr(“href”, “tel:” + url_format);
});
})(jQuery);
</script>
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.