I am creating a wordpress plugin of my own when I got stumble to this kind of error. An error that takes a lot of my time to resolve this kind of problem. I got into most of the forums about WordPress that has the same problem with mine. Some may have a smiling face with their solutions but I have a sad face since it does’nt solve the problem on my wordpress installed on my localhost server. I tried using headers instead of wp_redirect hoping there could be any changes of not using wp_redirect instead I use headers but still no changes at all. After a long hours of searching and playing pc games just to loosen the feeling of being frustrated of solving a one line code, I got into a forum and found the answer. This is another work around of redirecting without using wp_redirect.
The problem:
Using wp_redirect in my plugin result to a Warning message : Cannot modify header information – headers already sent by… And did’nt get a redirected page that i need.
The Solution:
Instead of using wp_redirect , echo location using meta
Instead of
USE THIS
[php]
<?php echo "<meta http-equiv=’refresh’ content=’0;url=$location’ />"; ?>
[/php]
It works on my wordpress plugin. I hope it works in your installed wordpress.
brilliant solution. I spent hours looking for the solution for wp_redirect() but it doesn’t work for me. I’m a WordPress new babie. Thanks so so much guy. Simple but effective solution!!!
thanks for help it work for redirect my url
Thank you so much, it works for me and saved hours of R&D.
I agree this does work in a pinch. If you can edit php_ini (either directly or now some settings are available through cPanel for my church’s site) then try to turn on output_buffering. If output_buffering is on in PHP then you will get much better results from wp_redirect. You can check output_buffering in phpinfo() and generally no value means it’s not on, so ask your host or check cPanel for EZconfig for php.ini.
If you do use the meta redirect, you can add an exit() statement right after the meta redirect to stop processing the page since meta refresh will redirect after the page completes loading, so exit() speeds that along in most cases π
Wow, greet help..
thanks a lot
try using this line of code:
echo “”;
Great job! – I’d tried many other more complex solutions – and this was so simple. Thanks for the solution.
This work like a charm. Thank you for your smart solution!
[…] ?WordPress wp_redirect problem : Warning: Cannot modify header information – headers already se…? […]
Osum dude….Very Very Nice Solution……Thanks a lot..:)
Thanks Andrew,
That was a great help.. π π
Thanks for the idea and it was a great help also. thanks
This is working for my plugin. Thanks to provide useful information.
thanks
you are great
THANKS! You saved my afternoon!