wp_redirect()
It is a wordpress function that redirects to the specified URL. It is simply understood that the page can jump to the specified URL address through this function, and the specified status code can be set, such as 301, 302, etc.
function code
one | wp_redirect ( string $location , int $status = three hundred and two , string $x_redirect_by = 'WordPress' ) |
Parameter description:
$location
– String, required. The URL to be redirected to must be an absolute URL address, not a relative address. The default value is empty (if the value is empty, false is returned)
$status
– Integer, optional, HTTP status code when jumping, default is 302 (temporary redirection status code)
$x_redirect_by
– String, optional, the application that executes redirection, and the default value is "WordPress"
Example
one two three four | <? php wp_redirect ( ' https://www.boke8.net/ ' , three hundred and one ) ;
exit ;
?> |
Tips: because wp_redirect()
The function does not automatically exit, so the exit
, if you need to continue, you do not need to add it.
Function location: wp-includes/pluggable.php
Wordpress official documents: https://developer.wordpress.org/reference/functions/wp_redirect/