Question:
I am trying to create a simple login system in WordPress using core PHP but I am getting this error messageWarning: Cannot modify header information – headers already sent by (output started at /www/www/www/wp-content/themes/mytheme/header.php:20) in /www/www/www/wp-content/themes/mytheme/page-solutions.php on line 9
In the
header.php
template I havepage-solutions.php
page
As you can see I am trying to redirect not logged users to front-page.php
which I called it Home but I am getting error on header("location: home");
Can you please let me know how to fix this?
Answer:
Functions that modifies headers must be called before any output is made. In this case you’re calling get_header() functions which sends an output, and then youre trying to modify the header. Try changing the order that you execute the code, like this:
If you have better answer, please add a comment about this, thank you!