# 8.12 \[lcw\_redirect]

The `[lcw_redirect]` shortcode allows you to redirect users to a **site-relative URL** after an optional delay. You can also display custom content during the wait time.

#### 🔧 Shortcode Usage

```wordpress
[lcw_redirect url="/thank-you" delay="5" target="_self"]
    Please wait 5 seconds... redirecting.
[/lcw_redirect]
```

#### 🧩 Attributes

| Attribute | Type   | Description                                                                                                                   |
| --------- | ------ | ----------------------------------------------------------------------------------------------------------------------------- |
| `url`     | string | **(Required)** Relative URL path (e.g., `/thank-you`). don't use the full url like <kbd><http://mydomain.com/thank-you></kbd> |
| `delay`   | int    | Delay in seconds before the redirection happens. Default: `0` (instant redirect).                                             |
| `target`  | string | Where to open the link: `_self`, `_blank`, `_parent`, or `_top`. Default: `_self`.                                            |

####

#### 💡 Features

* ✅ **Site-relative URL**: Automatically prepends your WordPress site's home URL to the `url` attribute.
* 💬 **Custom Content**: Shows a message or HTML while waiting for the redirect.
* ⏱️ **Delay**: Uses a delay for the redirect.
* 🔀 **Supports Nested Shortcodes**: Works with shortcodes inside both attributes and content.
* 🔐 **Sanitized Inputs**: Ensures clean and safe output with `esc_url()` and `esc_attr()`.

#### 🧪 Example Scenarios

**Redirect after delay with message:**

```wordpress
[lcw_redirect url="/thank-you" delay="3"]
    You will be redirected in 3 seconds...
[/lcw_redirect]
```

**Immediate redirect with no message:**

```wordpress
[lcw_redirect url="/login"]
```

**Redirect to open in a new tab:**

```wordpress
wordpressCopyEdit[lcw_redirect url="/external-resource" target="_blank" delay="2"]
    Opening in a new tab...
[/lcw_redirect]
```

***

#### ⚠️ Error Handling

* If `url` is empty or not provided:

  ```
  URL is required for redirect shortcode
  ```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://better-wizard.gitbook.io/lead-connector-wizard/shortcodes/lcw_redirect.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
