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?
hidden link was intended for the second one. I think your filter added the http://
Yeah it did it again. We just want the part starting with www to display.
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]
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.
Please provide your website credentials in below private message box, thanks
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.
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.
That's working. Thanks hugely! Great work.
My issue is resolved now. Thank you!