wp redirect – Why “exit” is needed after wp_redirect?


When you call wp_redirect it sends redirect HTTP headers, and that’s all the browser needs to redirect, there is no reason to continue executing code.

If you do not exit, WordPress will continue to run the rest of the page generation sequence, loading all the code, which may confuse the browser, or lead to generating HTML the browser has no interest in, as well as wasting server resources.

Afterall why would you continue loading the page if the server has told you to go to a new location?

shenkwen 1 month 2021-12-21T16:02:39-05:00 0 Answers 0 views 0

Leave an answer