Skip Navigation

[Resolved] Add link to a single line 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 -

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

This topic contains 7 replies, has 2 voices.

Last updated by Jaime 1 year, 5 months ago.

Assisted by: Minesh.

Author
Posts
#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

Languages: English (English )

Timezone: 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 hidden link instead hidden link)
So when I click on a website link with your code it sends my to
hidden link
instead to
hidden link

Can you guess another workaround?
Thank you!

#2495987

Minesh
Supporter

Languages: English (English )

Timezone: 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

Languages: English (English )

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

On your Edit Layout's last row I've added the following shortcode:
- hidden link

<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":
=> hidden link

function func_check_http($attr,$content) {
  if(!empty($attr['field'])) {
    if(strpos($attr['field'], '<em><u>hidden link</u></em>') !== 0) {
        return '<a href="<em><u>hidden link</u></em>'.$attr['field'].'" target="_blank">'.$attr['field'].'</a>';
    }
  	if(strpos($attr['field'], '<em><u>hidden link</u></em>') !== 0) {
        return '<a href="<em><u>hidden link</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: hidden link
- 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
<a href="[types field='web-guia-produccion' ][/types]"> [types field='web-guia-produccion'][/types] </a>
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

Languages: English (English )

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

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.