#2751 closed enhancement (invalid)
Placement of wp_redirect()
| Reported by: |
|
Owned by: | |
|---|---|---|---|
| Milestone: | Priority: | normal | |
| Component: | Developer Hub | Keywords: | |
| Cc: |
Description
It doesn't say on | 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();
Change History (3)
Note: See
TracTickets for help on using
tickets.
Hi @milana_cap, thanks for the suggestion! There are two places where such a request can be better handled: