• Resolved joshamo

    (@joshamo)


    So I put this

    <?php if(is_mobile() && get_the_ID() == 7) {
    
    wp_redirect('http://www.google.com');
    
    exit;}
    
    ?>

    in my header.php, because I read somewhere that is where I should put it. However, I get an error when I visit page id 7 on a mobile browser.

    Warning: Cannot modify header information – headers already sent by (output started at /home/mysite/public_html/mysite.net/wp-content/themes/childtheme1/header.php:13) in /home/mysite/public_html/mysite.net/wp-includes/pluggable.php on line 1173

    https://wordpress.org/plugins/php-browser-detection/

Viewing 1 replies (of 1 total)
  • Plugin Author Mindshare Labs, Inc.

    (@mindshare)

    Double check you don’t have any whitespace in header.php or index.php before the PHP code executes. You could also try putting this in index.php, above the HTML opening tag.

Viewing 1 replies (of 1 total)
  • The topic ‘Trying to redirect one page only, getting an error on mobile.’ is closed to new replies.