WordPress.org

Ready to get started?Download WordPress

Forums

WP Mobile Detect
header.php and mobile detect (4 posts)

  1. jasamizosijeka
    Member
    Posted 1 year ago #

    Hello,

    it is about header.php
    i am trying to show this two divs ( with rest ofcourse) on just computers ( not phone or tablets)
    here is my code

    <div id="pozadinadesno" style="background:url('http://www.psc-osijek.hr/slike/manja.jpg');height:854px;width:277px;float:left;left : 50%; margin-left: -765px;margin-top : 152px; position:absolute ">
    </div>
    <div id="pozadinadesnije" style="background:url('http://www.psc-osijek.hr/slike/manja.jpg');height:854px;width:277px;float:left;left : 50%; margin-left: 488px;margin-top : 152px; position : absolute">
    </div>

    when i change it
    to

    `
    <?php include 'wp-mobile-detect/mobile-detect.php';
    if (function_exists('wpmd_is_phone') && wpmd_is_phone()) {
    }
    else
    { <div id="pozadinadesno" style="background:url('http://www.psc-osijek.hr/slike/manja.jpg');height:854px;width:277px;float:left;left : 50%; margin-left: -765px;margin-top : 152px; position:absolute ">
    </div>
    <div id="pozadinadesnije" style="background:url('http://www.psc-osijek.hr/slike/manja.jpg');height:854px;width:277px;float:left;left : 50%; margin-left: 488px;margin-top : 152px; position : absolute">
    </div>
    }
    ?>

    it shows arse error: syntax error, unexpected '<' ....

    hmmm?

    http://wordpress.org/plugins/wp-mobile-detect/

  2. jasamizosijeka
    Member
    Posted 1 year ago #

    and if i put just this line of code

    if (function_exists('wpmd_is_phone') && wpmd_is_phone()) { echo ""; }

    web page loads but shows that line of code ( , like it is not recognized... )

    newb :(

  3. jasamizosijeka
    Member
    Posted 1 year ago #

    <?php if (function_exists('wpmd_is_phone') && wpmd_is_phone()) { echo "mobitel"; }
    else {
    echo "desktop";
    }
    ?>

    i inserted this into header.php ...
    now it works like it echo's mobitel // desktop, it works ok ....
    but how to insert divs into this if statement :S

  4. maheksiddique
    Member
    Posted 1 month ago #

    I guess first you have to detect the user device and then you can detect the browser after that try to change your code accordingly.
    Read create mobile compatible website for more details

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags

No tags yet.