Dutch Flag Dutch speaking WordPress / Gravity Forms developer? Apply now!

Documentation

gwp_url

The gwp_url Merge Tag for Gravity Forms is able to return the WordPress site url, the WordPress home url, the current url, or an element of the current url.

The gwp_url merge tag has the following possible parameters:

Type parameter

The type parameter determines what url component to return. It has the following possible values:

  • site_url: Returns the URL for the current site where WordPress application files are accessible.
  • home_url: Retrieves the URL for the current site where the front end is accessible (basically what users need to type in their browser url to reach your site).
  • scheme: Returns http or https.
  • domain: Returns the full domain or a part of it if combined with the index parameter.
  • path: Returns the full path after domain, or a part of it when combined with the index paramater.

Index parameter

The index parameter is an optional parameter to retrieve a part of the URL-path or domain. It must be an integer value. A positive value returns the element counted from the left, starting with 0. A negative value returns the element counted from the right.

How to use the gwp_url merge tag

{gwp_url type= index=}
ExamplesOutput
{gwp_url}https://gravitywp.com/doc/gwp_url/
{gwp_url type=site_url}https://gravitywp.com
{gwp_url type=home_url}https://gravitywp.com
{gwp_url type=scheme}https
{gwp_url type=domain}
{gwp_url type=domain index=-1}
{gwp_url type=domain index=0}
gravitywp.com
com
gravitywp
{gwp_url type=path}
{gwp_url type=path index=-1}
{gwp_url type=path index=-2}
/docs/gwp_url/
gwp_url
docs

Subdomain url

How does it work on a subdomain? Check it out.

ExamplesOutput
{gwp_url type=domain}test.com
{gwp_url type=domain index=-2}ddev
{gwp_url type=domain index=-1}site
{gwp_url type=domain index=0}test
{gwp_url type=domain index=1}ddev
{gwp_url type=domain index=2}site

Last updated: 06-12-2024

Advanced Merge Tagsv1.8.4

To use the functionalities described in this documentation, you'll need to get the GravityWP - Advanced Merge Tags add-on.

Read more