Filters the redirect location.
Parameters
$locationstring- The path or URL to redirect to.
$statusint- The HTTP response status code to use.
Source
$location = apply_filters( 'wp_redirect', $location, $status );
Changelog
| Version | Description |
|---|---|
| 2.1.0 | Introduced. |
Overview of wp_redirect Hook
The
apply_filters( 'wp_redirect', string $location, int $status )hook in WordPress allows developers to modify the redirect URL ($location) and the HTTP status code ($status) before WordPress executes a redirection. This can be useful for modifying or validating the destination URL or for changing the response code to suit specific needs.In this example, if the redirect URL contains “permanent,” the status code changes to 301.
$locationvalue. To change the$statusvalue, use thewp_redirect_statushook.