Skip to content

Instantly share code, notes, and snippets.

@mmh4560
Last active December 13, 2018 17:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mmh4560/ea1ec7fccc1581f45923bf9d2bc2794d to your computer and use it in GitHub Desktop.
Save mmh4560/ea1ec7fccc1581f45923bf9d2bc2794d to your computer and use it in GitHub Desktop.
<?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;
}
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment