Advertisements

wp_redirect

Definition:
function wp_redirect($location, $status = 302) {}

Redirects to another page.

Parameters

  • string $location: The path to redirect to
  • int $status: Status code to use

Return values

returns:False if $location is not set

Defined filters

  • wp_redirect
    apply_filters('wp_redirect', $location, $status)
  • wp_redirect_status
    apply_filters('wp_redirect_status', $status, $location)

Source code

function wp_redirect($location, $status = 302) {

	global $is_IIS;



	$location = apply_filters('wp_redirect', $location, $status);

	$status = apply_filters('wp_redirect_status', $status, $location);



	if ( !$location ) // allows the wp_redirect filter to cancel a redirect

		return false;



	$location = wp_sanitize_redirect($location);



	if ( !$is_IIS && php_sapi_name() != 'cgi-fcgi' )

		status_header($status); // This causes problems on IIS and some FastCGI setups



	header("Location: $location", true, $status);

}

4015

Advertisements

No comments yet... Be the first to leave a reply!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: