8.12 [lcw_redirect]

[this is a free feature]

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

[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 http://mydomain.com/thank-you

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:

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

Immediate redirect with no message:

[lcw_redirect url="/login"]

Redirect to open in a new tab:

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

Last updated