Как отображать контент только для мобильных или настольных ПК, используя WordPress «wp_is_mobile».

Метод первый. Просто используйте IFусловия в своих шаблонах:

<?php  if( wp_is_mobile()){  ?>
// mobile stuff goes here
<?php } else { ?>
// desktop stuff goes here
<?php  } ?>
<?php
if ( wp_is_mobile() ) {
	/* Include/display resources targeted to phones/tablets here */
} else {
	/* Include/display resources targeted to laptops/desktops here */
}
?>

Метод второй. Этот фрагмент позволит вам использовать шорткоды [desktoptoponly] desktop content [/ desktoponly] или [mobileonly] mobile content [/ mobileonly], чтобы определить, какой контент должен быть возвращен посетителю:

<?php 
// [desktoponly] shortcode
add_shortcode('desktoponly', 'wp_snippet_desktop_only_shortcode');
function wp_snippet_desktop_only_shortcode($atts, $content = null){ 
    if( !wp_is_mobile() ){ 
        return wpautop( do_shortcode( $content ) ); 
    } else {
        return null; 
    } 
}
// [mobileonly] shortcode
add_shortcode('mobileonly', 'wp_snippet_mobile_only_shortcode');
function wp_snippet_mobile_only_shortcode($atts, $content = null){ 
    if( wp_is_mobile() ){ 
        return  wpautop( do_shortcode( $content ) ); 
    } else {
        return null; 
    } 
}
?>

Изменение класса body

/* Filter body class */
add_filter('body_class','shellcreeper_theme_body_class');

/**
 * Add Mobile Body Class "wp-is-mobile" for mobile
 * and "wp-is-not-mobile" for non-mobile device
 * 
 * @since 0.1.1
 * @link http://codex.wordpress.org/Function_Reference/wp_is_mobile
 */
function shellcreeper_theme_body_class( $classes ){

    /* using mobile browser */
    if ( wp_is_mobile() ){
        $classes[] = 'wp-is-mobile';
    }
    else{
        $classes[] = 'wp-is-not-mobile';
    }
    return $classes;
}
jQuery( document ).ready( function($) {

    if ( $( "body" ).hasClass("wp-is-mobile"){
        /* Do javascript for mobile */
    }
    else{
        /* Do javascript for non-mobile */
    }

});

Источник

wp_is_mobile()