[wp-trac] [WordPress Trac] #41204: Placement of wp_redirect() in	template
    WordPress Trac 
    noreply at wordpress.org
       
    Thu Jun 29 13:15:08 UTC 2017
    
    
  
#41204: Placement of wp_redirect() in template
-------------------------+-----------------------------
 Reporter:  milana_cap   |      Owner:
     Type:  enhancement  |     Status:  new
 Priority:  normal       |  Milestone:  Awaiting Review
Component:  General      |    Version:
 Severity:  normal       |   Keywords:
  Focuses:  docs         |
-------------------------+-----------------------------
 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://core.trac.wordpress.org/ticket/41204>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
    
    
More information about the wp-trac
mailing list