Recognize if device is desktop or mobile

Recognize if device is desktop or mobile

Part of code that you can implement into theme in case you need to separate visibility of content regarding type of device.

<?php

$useragent = $_SERVER[‘HTTP_USER_AGENT’];
$iPod = stripos($useragent, “iPod”);
$iPad = stripos($useragent, “iPad”);
$iPhone = stripos($useragent, “iPhone”);
$Android = stripos($useragent, “Android”);
$iOS = stripos($useragent, “iOS”);
//– You can add billion devices

$DEVICE = ($iPod||$iPad||$iPhone||$Android||$iOS);

if (!$DEVICE) { ?>

echo ‘Desktop content here’;

<?php }else{?>

echo ‘Mobile content here’;

<?php }?>

Twitter
Facebook
LinkedIn
Telegram
WhatsApp
Email