You should not be executing anything before your DOCTYPE tag. That will all be invalid code and is also the issue leading to your error.
In general, any output like above should be done after the <head></head> tags, although some prefer to hook into the wp_head hook to execute functions like your code. I do prefer however to move such code after the closing head tag.
So your solution would be to move your conditional code to just after the closing head tag
Related Posts:
- create a button in the header of the mobile menu in the middle of the logo and the menu accordion
- How to hide or change mobile header logo with Additional CSS or custom PHP
- What is the difference between “SMS Push” and “WAP Push”?
- Proper usage of wp_is_mobile()?
- How do I make my blog iPad / iPhone / Android friendly?
- WordPress REST endpoint with JSON for Mobile App integration
- WordPress on WP7
- Developing mobile version of WordPress site
- How can i disable a plugin for a mobile phone?
- How can I make a wp site in a mobile application?
- Mobile Menu Not Showing
- Create mobile navigation header with settings integration
- Querying custom fields with Carrington mobile theme
- Is there any mobile application for WordPress? [closed]
- detect screen width in functions
- A URL that links specifically to the mobile version of my site?
- How to disable/enable specific plugins for a mobile theme?
- Elements floating on top of each other when Resizing or checking site on mobile. Twenty Twelve
- Mobile theme not showing correct page after custom re-writes
- My website is not responsive on mobile devices
- Best method for loading content on mobile – issue with wp_is_mobile
- Why is only one page responsive? [closed]
- Strategy for making a mobile version of an existing site? [closed]
- How can I redirect mobile users to diff url, but also allow them to come back to full site
- Open Menu is not working in Mobile view [closed]
- WordPress website loads fine on desktop browsers but Safari for iOS cannot load it completely [closed]
- Static page for desktop or mobile
- $is_iphone – to redirect a page
- Quick login from mobile phone
- How can I use my blog page as the homepage but only for mobile/tablet visits?
- Dropdown menu not displaying in handheld slide menu effect
- How to disable the topbar in mobile? [closed]
- WordPress mobil will not scroll
- Disable rendering of objects on mobile/above certain screen resolution
- Adapting “wide with” Gutenberg blocks for mobile
- Close Mobile Slide Menu on Click
- How can I hide/show text only for mobile users?
- Different Home page for Mobile without changing URL
- App in wordpress doesnt fit to mobile screen
- Add audio post from smartphone
- Display posts on a map
- responsive website
- Mobile Menu not working on TwentyThirteen child theme
- change theme when on mobile and also on Ipad portrait view
- Subdomain for WP Mobile Edition and Cloudfare
- How can I stop Jetpack mobile theme from using full size featured images?
- website is viewing as mobile, how do I turn this off?
- Work on two different themes at the same time in wordpress
- How to disable fancybox on small screens
- Add exception to WP Mobile Detector
- Using WordPress as a Mobile App Backend
- WordPress Mobile Edition not working with WP v3.5
- Why doesn’t the mobile version of my website take updates?
- Links not showing up on “AMPforWP”
- Viewing a WordPress website in landscape [closed]
- different startsite for IOS and change menu
- wordpress fancybox responsive mobile or pc version [closed]
- Separate Mobile site
- Not able to see updates my mobile after making updates on wordpress mobile version
- Not working Mobile view and Desktop view properly when we searched on website
- Mobile App Not Posting, Debugging Options
- How can I edit a .jar file?
- Create mobile site with same content just different theme
- Using a Theme inside a Plugin directory
- Using subdomain m.website.com for mobile theme?
- Uber menu, manual integration, disable Mobile
- Add additional upload field to Custom Header page
- What does $_GET[‘iphone’] do?
- Replace the slug of parent pages with # [closed]
- Review site using WordPress
- Menu toggle bar works only on some pages in WordPress
- Row background image not showing in mobile browser served from wamp local host
- Page header menu links change
- Web App mode leaves users stranded when following image links when using WPTouch with W3 Total Cache [closed]
- How to redirect non logged in mobile users to page on same site?
- WordPress website – Mobile menu behavior help
- Exclude ipads and tablets form wp_is_mobile code
- AMP and Paypal form CORS issue
- Change mobile menu color from red to another color
- How to center entire columns on a page, and have it stay responsive?
- woocommerce Shortcodes – Change display between mobile and Desktop
- use css for resize image into mobile thumbnail
- Links open when scrolling on touch devices/mobile
- Upload image to wordpress using ionic/cordova with WP REST API V2
- WordPress 4.4.2, _s starter theme, problems with custom default header
- Jetpack Mobile Theme: when on smartphone on categories the theme suddenly changes to jetpack mobile theme even though it’s deactivated
- How to create a custom header?
- Templates for Mobile Site
- How to display the link that says “Edit Header Image” on header image
- Dynamic Title for custom post types
- Display the current post author and his url in the post header
- Set header for default posts page?
- Creating a custom header
- How to laod wp_enqueue_style to another header i created my self
- Center-Align Images on Mobile Only
- How to implement a custom sliding banner? [closed]
- How can I directly upload smartphone videos to blog and comments?
- Header and Footer options in pages and posts
- How can I only show one responsive menu on mobile devices?
- How do i create a switch for responsive devices?