[wp-meta] [Making WordPress.org] #2751: Placement of wp_redirect()
Making WordPress.org
noreply at wordpress.org
Wed Apr 19 08:03:32 UTC 2017
#2751: Placement of wp_redirect()
---------------------------+-----------------
Reporter: milana_cap | Owner:
Type: enhancement | Status: new
Priority: normal | Milestone:
Component: Developer Hub | Keywords:
---------------------------+-----------------
It doesn't say on
[https://developer.wordpress.org/reference/functions/wp_redirect/ | this
page] where in template file should wp_redirect() function be called. If
placed in wrong place, there could be created confusion and impression
that function doesn't work.
So, it should be placed '''before''' get_header();
In case page is redirected only under certain condition, it would be
something like:
{{{
/**
* Redirect only if this condition is met
*/
if ( certain_condition ) {
wp_redirect( $location );
exit;
}
/**
* Otherwise render the page
*/
get_header();
}}}
--
Ticket URL: <https://meta.trac.wordpress.org/ticket/2751>
Making WordPress.org <https://meta.trac.wordpress.org/>
Making WordPress.org
More information about the wp-meta
mailing list