How to shorten the displayed URL in a Website field

If your entries have long URLs, they can look bad when displayed in a View. GravityView offers a Website field option named "Shorten Link Display," which allows you to change a long, ugly URL to a nice-looking one.

  • It will take this: https://www.example.com/las8fh/742m.html?ref=product137u
  • And turn it into this: example.com

The "Shorten Link Display" functionality is enabled by default for Gravity Forms Website fields in a View.


Here's how to enable and disable the functionality:

Click the Add Field button

Select a Website field from the field picker

If your form doesn't have a website field, this functionality will not be available.

Click the gear icon to configure the Field settings

Check or uncheck the "Shorten Link Display" setting

By default, links will be shortened by removing:

The link text will look shorter, but the link URL remains the same.

For developers: Hooks to modify "Shorten Link Display" behavior

If you would like to tweak how the Shorten Link Display functionality works, there are hooks for that!

You can find the hooks inside the gravityview_format_link() function. You can also override the function by defining it in your theme's code>functions.php file.

The following hooks are available to modify functionality. All filters have a true default.

  • http:// and https:// (or any other scheme, like ftp://)  ( http://example.com => example.com )
    Filter: gravityview_anchor_text_striphttp
  • www. subdomain, if exists ( www.example.com => example.com )
    Filter: gravityview_anchor_text_stripwww
  • Subdomains, if exists ( demo.example.com => example.com )
    Filter: gravityview_anchor_text_nosubdomain
  • URL paths ( http://example.com/sub/directory/page.html => example.com )
    Filter: gravityview_anchor_text_rootonly
  • Query parameters ( http://example.com/?query=example => example.com )
    Filter: gravityview_anchor_text_noquerystring

See a code sample for disabling Shorten Link Display filters.