This is related to this topic about phone formats, but since it’s been closed, I can’t update that post. So with that in mind, any idea when we’ll have an update to this issue. Since I’m in the US and the phone format display is still more European style?
Yes, if you mean displaying the phone number of the listing page (not in the Phone field, it should be already ok) - we have this in the bug tracker so we’ll try to release a fix as soon as possible.
Hope so. We’re about a week or so away from launching and this is really important.
Any update on this? We’re launching this week and can’t do it without this issue resolved.
We’re already testing the update, but if it’s urgent I can post a temporary fix for this, let me know if this works for you (in this case please provide the attribute name that stores the phone number).
Please try this PHP snippet
add_filter(
'hivepress/v1/fields/phone/display_value',
function($value){
$listing = hivepress()->request->get_context('listing');
if(!$listing){
return $value;
}
return preg_replace('~.*(\d{3})[^\d]{0,7}(\d{3})[^\d]{0,7}(\d{4}).*~', '+1 $1 $2 $3', $value);
},
1000
);
Thank you. I did. But I still see the same phone format. Was there something else I was supposed to do?
Please make sure that you have put this code snippet with the Code Snippets plugin or the similar one
If the issue persists, please provide more details on how you have put this code snippet on your website
What’s so wrong about putting it into functions.php of the child theme? Because that’s where it is. Shouldn’t need a Code Snippets plugin.
There’s nothing wrong with it - it’s also a valid way to keep the custom snippets, but we suggest the Code Snippets plugin by default because 99% don’t use the child theme (it’s required for overriding template parts only).
Please try this code snippet instead, I tested it with US phone numbers and it seems to work:
add_filter(
'hivepress/v1/fields/phone/display_value',
function($value){
return preg_replace('/(\+1)(\d{3})(\d{3})(\d{4})/', '$1 ($2) $3-$4', $value);
},
1000
);
I tested +11231231234 number Screenshot by Lightshot
It’s better but it’s still not it. Phone number comes in as +1 (626) 555-1212 instead of just (626) 555-1212.
In other words, no +1.
Please try this PHP snippet
add_filter(
'hivepress/v1/fields/phone/display_value',
function($value){
return preg_replace('/(\+1)(\d{3})(\d{3})(\d{4})/', '($2) $3-$4', $value);
},
1000
);
Yep, that made all the difference. Thank you.
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.