Support

Account

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

Solving

Phone field with href="tel:" link

  • Hi y’all,
    I need to make a phone field but I need it to be linked to itself. I mean
    <a href="tel:{phone-number}"> {phone-number}</a>

    I get that there are two fields for “before” and “after” where i can put the <a> and </a> tags, but how can i call the field’s value inside one of it?

    Of course, I am using the number type field. Is there a way to do it with url type?

  • The before and after are only for display of the field in the admin.

    You need to do this work yourself in the template file

    
    $phone = get_field('phone-number');
    <a href="tel:<?php echo $phone; ?>"><?php echo $phone; ?></a>
    
    • amos

    • August 14, 2019 at 9:14 am

    hi @hube2 🙂
    Where should I put the code? Or what file should I edit?
    I want to put the command in all the posts on my site.
    BTW, I learn a lot from you here, thank you!

  • The code goes wherever you’re getting and showing the ACF field in your templates.

    • amos

    • August 14, 2019 at 9:49 pm

    Ok, weird, didn’t work for me, I’ll try again 🙂

    tnx again!

Viewing 5 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic.

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 Cookie Policy. If you continue to use this site, you consent to our use of cookies.