Saltar navegación

[Resuelto] Phone field

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Zona horaria del colaborador: Asia/Kolkata (GMT+05:30)

Este tema contiene 9 respuestas, tiene 1 mensaje.

Última actualización por danielL-13 1 year ago.

Asistido por: Minesh.

Autor
Mensajes
#2809124

Tell us what you are trying to do?

Display a phone number as a link.
I am using a "phone" custom field.

I want the diplayed number be something like +43 123 456 78.

Basically i want this: enlace oculto

How can i achive that? Do i need 2 custome fields - one for the "pretty" number and one for the link?

Or is there a better way to achive that?

Thanks,
Daniel

#2809131

Minesh
Colaborador

Idiomas: Inglés (English )

Zona horaria: Asia/Kolkata (GMT+05:30)

Hello. Thank you for contacting the Toolset support.

Well - you can enable the legacy view's if its not eanabled. Please check the following Doc:
=> https://toolset.com/course-lesson/enabling-legacy-version-of-toolset-views/

After that - you can add "Fields and Text" block or shortcodes block if you are using blocks and add the following to it:

<em><u>enlace oculto</u></em>
#2809136

Hi Menish,

thanks!

So this shortcode stripe empty spaces in the number when adding the link, right?

#2809142

Minesh
Colaborador

Idiomas: Inglés (English )

Zona horaria: Asia/Kolkata (GMT+05:30)

It will not strip the empty spaces it will display the number filed value as you submitted in backend.

#2809149

But this means, i would have to enter the number in the phone-field without empty spaces?
Or is this not a problem and it will work with empty spaces like +43 676 123 456 67 ?

#2809156

Minesh
Colaborador

Idiomas: Inglés (English )

Zona horaria: Asia/Kolkata (GMT+05:30)

If you want to keep space and plus sign (+43) then you will have to use the normal "single line" custom field instead of number field. Single field will allow you to add plus sign as well as space and numbers.

So instead of phone type custom field you should conver this field to "single line" field.

#2809160

But i do have this format in my phone field right now: +43 676 123 456 67
The question is: If this value is now output in the short code as


Minesh
Colaborador

Idiomas: Inglés (English )

Zona horaria: Asia/Kolkata (GMT+05:30)

You should first try the solution I shared and check:

	
<em><u>enlace oculto</u></em>

It should work.

#2809357
Bildschirmfoto 2025-05-19 um 09.30.54.png

Sorry, my previous message got cut off.
Yes, of course I tried the shortcode.

I noticed that the phone number I entered – with spaces for better readability – is also rendered with spaces inside the href of the


Minesh
Colaborador

Idiomas: Inglés (English )

Zona horaria: Asia/Kolkata (GMT+05:30)

For that - you will have to write the custom shortcode - you can add the following shortcode to "Custom Code" section offered by Toolset:
=> https://toolset.com/documentation/programmer-reference/adding-custom-code/

function remove_all_spaces_shortcode($atts, $content = null) {
    if ($content === null) return '';
    
    // Remove all whitespace (left, right, and middle)
    $trimmed = preg_replace('/\s+/', '', $content);
    
    return $trimmed;
}
add_shortcode('remove_spaces', 'remove_all_spaces_shortcode');

And call this shortcode as:

[remove_spaces][types field='phone-field-slug'][/types][/remove_spaces]
#2809528

Thanks! That's what i was looking for!