WordPress.org

Support

Support » Plugins and Hacks » WP Mobile Detect » header.php and mobile detect

header.php and mobile detect

  • 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/

Viewing 3 replies - 1 through 3 (of 3 total)
  • 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 🙁

    <?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

    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

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘header.php and mobile detect’ is closed to new replies.
Skip to toolbar