Make phone number callable

I was trying to make the phone number clickable. I searched it within this community, I found one but it’s sending to “page not found”

Help me on this matter please.

Thank you!

Hi! Try this in the phone attribute “Format field”

%label%: <a href="tel:%value%" data-title="%value%" rel="nofollow">Call %icon%</a>

The rel=“nofollow” maybe not neccessary, because google not indexing phone numbers now. Select a phone icon to display if you want, but if not, delete the %icon% command. In this sample, the numbers will not displayed, just the “Call” and the user need to click on the call link.

1 Like

Perfect. Thank you for your help.

One for thing. Usually the phone numbers start with 0 locally and omitted when country code is added. Most of the people will start with the 0, how can I make delete itself automatically so that it does not create a problem when calling, please?

I am looking forward for your help. Thank you

I’am using a sample phone number in the attribute’s placeholder field, to show, what is the correct format, and in the “note” field, you can write a short description: “Please use this phone number format: yourphonenumbersamplehere” alternatively you can use a regex pattern, but that is not so simple to make, if you want the pattern accept mobile an wired, and phone numbers from other countries.

Great. I will see which option suits me. Thanks again. God bless you!

1 Like

this code snipper worked for me.

// Filter to modify phone number attribute
add_filter( 'hivepress/v1/models/listing/attributes/phone', 'custom_modify_phone_number', 10, 2 );

function custom_modify_phone_number( $value, $listing_id ) {
    // Check if the phone number starts with 0
    if ( substr( $value, 0, 1 ) === '0' ) {
        // Remove the first digit (0)
        $value = substr( $value, 1 );
    return $value;
1 Like