Conditional Tags Worpress for mobile devices

0

How do I use a Conditional Tag in my wordpress theme so that a particular script is not loaded on mobile devices. Is there such a tag?

If it exists could you show me an example?

In this example the script would only load in the home of the site, I would like a code that checks that the device is mobile the script would not load. or would not appear in the source code.

 <?php if( is_home() ): ?>

 <script data-cfasync="false" type="text/javascript" src=""></script>

 <?php endif; ?>
    
asked by anonymous 16.09.2015 / 22:52

1 answer

1

Use the wp_is_mobile() function:

<?php
if ( wp_is_mobile() ) {
    /* Display and echo mobile specific stuff here */
}
?>

This function has been present in WordPress since version 3.4. See more details on codex .

    
16.09.2015 / 23:07