I want to use this code in a template file:
if ( wp_is_mobile() ) {
wp_redirect( "/shop-mobile", $status );
}
but it says: header already sent by /filewithcode in .../wp_includes/pluggable.php on line 1196
I tried to clean the pluggable document from spaces.. what else could be the issue here? Thank you
"To fix the "headers already sent" issue, you need to move all of your form processing from the bottom of the page to the top of the page. If you need to call wp_redirect() you must make that call before you print anything - HTML or anything else - to the page."
reference: https://wordpress.stackexchange.com/questions/81566/wp-redirect-headers-already-sent-after-front-end-submission-form
you can read this for more explanation of this problem
How to fix "Headers already sent" error in PHP
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With