Sauter la navigation

[Résolu] Add link to a single line field

This support ticket is created Il y a 2 années et 1 mois. 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 -

Supporter timezone: Asia/Kolkata (GMT+05:30)

Ce sujet contient 7 réponses, a 2 voix.

Dernière mise à jour par Jaime Il y a 2 années et 1 mois.

Assisté par: Minesh.

Auteur
Publications
#2495943

Tell us what you are trying to do?
I have a field containing url websites created using "Single Line Field", not "URL Field".
I need to use those Single Lines to add links to those url websites.

Is this posible?

#2495959

Minesh
Supporter

Les langues: Anglais (English )

Fuseau horaire: Asia/Kolkata (GMT+05:30)

Hello. Thank you for contacting the Toolset support.

Yes, you can build the link based on the URL available with your single line field.

If you are using Blocks then you should try to add shortcodes block and add the following code and adjust the field names as required.

For example:

<a href="[types field='field-slug' ][/types]"> your desired caption </a>
#2495967

Hi Minesh!
Sorry, but it doesn't work for me.
First of all, I'm not using Blocks.

I've tried your code and it's not working I guess, because people write their website in plain text (I mean, they wrote something like lien caché instead lien caché)
So when I click on a website link with your code it sends my to
lien caché
instead to
lien caché

Can you guess another workaround?
Thank you!

#2495987

Minesh
Supporter

Les langues: Anglais (English )

Fuseau horaire: Asia/Kolkata (GMT+05:30)

The workaround I shared should work. Can you please share problem URL and admin access details and what field holds the URL field value.

*** Please make a FULL BACKUP of your database and website.***
I would also eventually need to request temporary access (WP-Admin) to your site. Preferably to a test site where the problem has been replicated if possible in order to be of better help and check if some configurations might need to be changed.

I have set the next reply to private which means only you and I have access to it.

#2496021

Minesh
Supporter

Les langues: Anglais (English )

Fuseau horaire: Asia/Kolkata (GMT+05:30)

On your Edit Layout's last row I've added the following shortcode:
- lien caché

<p>[check_http field="[types field='web-guia-produccion' output='raw'][/types]"]</p>

And I've added the shortcode's code to "Custom Code" section with code snipeet "Toolset Custom code":
=> lien caché

function func_check_http($attr,$content) {
  if(!empty($attr['field'])) {
    if(strpos($attr['field'], '<em><u>lien caché</u></em>') !== 0) {
        return '<a href="<em><u>lien caché</u></em>'.$attr['field'].'" target="_blank">'.$attr['field'].'</a>';
    }
  	if(strpos($attr['field'], '<em><u>lien caché</u></em>') !== 0) {
        return '<a href="<em><u>lien caché</u></em>'.$attr['field'].'" target="_blank">'.$attr['field'].'</a>';
    } 
    return '<a href="'.$attr['field'].'" target="_blank">'.$attr['field'].'</a>';
  }else{
    return '';
  }
}
add_shortcode( 'check_http', 'func_check_http');

Can you please confirm it works as expected: lien caché
- You can see the link with URL as bottom of the page:

#2496033

Sorry Minesh, but as far as I see the behavior is the same.
Nothing seems to have changed despite your code.

I added this to the Layout
[types field='web-guia-produccion'][/types]
to try if it's working correctly, but as I told you, it seems to be exactly the same.
I left this code wrote on the Layout just to let you try again.

I'm not sure what its happening.
Thanks you Minesh!
🙂

#2496037

Minesh
Supporter

Les langues: Anglais (English )

Fuseau horaire: Asia/Kolkata (GMT+05:30)

Actually, you have to use the following shortcode wherever you want to display the link:

<p>[check_http field="[types field='web-guia-produccion' output='raw'][/types]"]</p>

Did you tried the aboe shortcode?

#2496043

My issue is resolved now. Thank you!