Skip Navigation

[Resolved] Hiding http:// or https:// from URL field label

This thread is resolved. Here is a description of the problem and solution.

Problem:

We have a URL field that we are displaying on a template as a URL link.

The link would still point to the full URL but the label display should remove the http:// . Is that possible?

Solution:

You might consider custom codes, for example:

https://toolset.com/forums/topic/hiding-http-or-https-from-url-field-label/#post-2277275

Relevant Documentation:

This support ticket is created 3 years, 3 months ago. 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
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9: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/Hong_Kong (GMT+08:00)

This topic contains 9 replies, has 2 voices.

Last updated by melodyM 3 years, 3 months ago.

Assisted by: Luo Yang.

Author
Posts
#2276911

We have a URL field that we are displaying on a template as a URL link. The output from this field is currently

hidden link

Is there any way to modify the label here to display as

hidden link

The link would still point to the full URL but the label display should remove the http:// . Is that possible?

#2276933

hidden link was intended for the second one. I think your filter added the http://

#2276935

Yeah it did it again. We just want the part starting with www to display.

#2277275

Hello,

There isn't such kind of built-in feature, according to URL definition, the "scheme" is required:
hidden link

You might consider custom codes, for example, create a custom shortcodes to remove scheme from link label, like this:
1) Add below PHP codes into your the Toolset custom codes snippet:

add_shortcode('my-url', function($atts, $content){
	$field = 'wpcf-' . 'my-url'; // replace my-url with your custom URL field slug
	$value = get_post_meta(get_the_ID(), $field, true);
	$label = preg_replace( "#^[^:/.]*[:/]+#i", "", $value );
	$res = '';
	if($value){
		$res = sprintf('<a href="%1$s" target="_blank">%2$s</a>', $value, $label);
	}
	return $res;
});

https://toolset.com/documentation/programmer-reference/adding-custom-code/

Please replace "my-url" with your custom URL field slug

2) use above shortcode like this:
[my-url]

#2277315

I think I did it right. I added the code to the custom code section in settings. I changed "my-url" to "website" everywhere it appeared, which is the slug for the website URL field. I added a new block with the shortcode [website] to the bottom of the template. But when I reload the page, it is only showing the shortcode, not executing it. You can see that here:

hidden link

I can provide access to the admin area if necessary.

#2277321

Please provide your website credentials in below private message box, thanks

#2277583

Please use the Shortcode block at the end of the template to apply what you will do here. Or replace the Shortcode block with however you have to do it. Please leave the existing Website field displaying with the http:// present.

#2278171

It should be a cache problem, I have done below modifications in your website:
1) Dashboard, click "Delete Cache" button
2) Dashboard-> Toolset-> Settings-> Custom codes, activate the item "remove-http-website-link",

Please test again, check if it is fixed.

#2280957

That's working. Thanks hugely! Great work.

#2281027

My issue is resolved now. Thank you!