Skip to main content

Request

Access HTTP request data. Available on all pages.

All Fields​

FieldArgumentsReturnsDescription
getkeymixedGET parameter value, or all parameters if no argument
postkeymixedPOST parameter value, or all parameters if no argument
url—stringCurrent URL, no query string
referrer—stringReferrer URL

url has no query string and no trailing slash. get and post give text: each value is cleaned with sanitize_text_field(), and a nested array becomes ''. Without a key, they give all parameters as a map, which you can loop over with {% for name, value in request.get %}.

Common Patterns​

Get URL parameter​

{{ request.get('category') }}
{{ request.get.sort }}

Get form input​

{{ request.post('name') }}
{{ request.post.email }}

Check for parameter with fallback​

{{ request.get('page') ?? 1 }}
{{ request.get('order') ?? 'asc' }}

Display current URL​

{{ request.url }}

In the editor​

The editor preview runs outside a visitor's request: url shows #, and the other fields are empty. Pattern library previews show nothing for this provider.

Request values come from the visitor, so square brackets are encoded ([ and ], or %5B and %5D in url and referrer): a visitor can't trigger a shortcode through the URL. They display as plain brackets. When you compare a value, compare it with its brackets encoded.

Watch out

A page cache stores the rendered page. request.referrer and request.post can be frozen into the cached copy and shown to other visitors: avoid them on cached pages.