Navigation überspringen

[Gelöst] Phone field

This support ticket is created vor 1 year. There's a good chance that you are reading advice that it now obsolete.

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 -

Zeitzone des Unterstützers: Asia/Kolkata (GMT+05:30)

Dieses Thema enthält 9 Antworten, hat 1 Stimme.

Zuletzt aktualisiert von danielL-13 vor 1 year.

Assistiert von: Minesh.

Author
Artikel
#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: versteckter Link

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
Unterstützer

Sprachen: Englisch (English )

Zeitzone: 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>versteckter Link</u></em>
#2809136

Hi Menish,

thanks!

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

#2809142

Minesh
Unterstützer

Sprachen: Englisch (English )

Zeitzone: 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
Unterstützer

Sprachen: Englisch (English )

Zeitzone: 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
Unterstützer

Sprachen: Englisch (English )

Zeitzone: Asia/Kolkata (GMT+05:30)

You should first try the solution I shared and check:

	
<em><u>versteckter Link</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
Unterstützer

Sprachen: Englisch (English )

Zeitzone: 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!