Opened 7 years ago

Closed 7 years ago

Last modified 7 years ago

#2751 closed enhancement (invalid)

Placement of wp_redirect()

Reported by: milana_cap's profile milana_cap Owned by:
Milestone: Priority: normal
Component: Developer Hub Keywords:


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 );
 * Otherwise render the page

Change History (3)

#1 @coffee2code
7 years ago

  • Resolution set to invalid
  • Status changed from new to closed

Hi @milana_cap, thanks for the suggestion! There are two places where such a request can be better handled:

  1. You can contribute a note to the reference page itself: You'll see there are already two User Contributed Notes for the function at the moment (though unrelated to your suggestion). That way any one else visiting the page can see your tip.
  1. If you feel this information deserves to be part of the function's inline documentation itself, you can open a ticket for it on and choose the "docs" focus. Inline docs are automatically added to the Code Reference when parsed after each WordPress release.

#2 @milana_cap
7 years ago

Hi @coffee2code,
sorry for missing the right place. Will post it as suggested. Thank you.

This ticket was mentioned in Slack in #forums by sergey. View the logs.

7 years ago

Note: See TracTickets for help on using tickets.