Skip to content

Instantly share code, notes, and snippets.

@metinsaylan
Created January 19, 2015 18:41
Show Gist options
  • Save metinsaylan/627e16adddba42e23d84 to your computer and use it in GitHub Desktop.
Save metinsaylan/627e16adddba42e23d84 to your computer and use it in GitHub Desktop.
WordPress desktoponly and mobileonly shortcodes
<?php
// [desktoponly] shortcode
add_shortcode('desktoponly', 'shailan_desktop_only_shortcode');
function shailan_desktop_only_shortcode($atts, $content = null){
if( !wp_is_mobile() ){
return wpautop( do_shortcode( $content ) );
} else {
return null;
}
}
// [mobileonly] shortcode
add_shortcode('mobileonly', 'shailan_mobile_only_shortcode');
function shailan_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