<?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;
}
}
?>
Now, we can wrap any text that should only be visible in the mobile browser with the shortcode [mobileonly][/mobileonly].
Example:
[mobileonly] This is a mobile only text. [/mobileonly]
Similar patterns apply to the desktop-only version as well.
Example:
[desktoponly] This is a desktop only text. [/desktoponly]
Video: Showing WordPress Mobile Only Content Using Plugin
Source link
Related posts:
Multiple Regression and Model Building
CATL prepares to expand production at German plant · TechNode
Natural acceptance of human values
Is Consolidated Media Buy a winning strategy? Let’s find out.
BAIC enters into strategic partnership with Bosch · TechNode
Management and Organization of the Logistics Systems
Are Hotels Ready for Generation Novel? How the rise of Generation-Novel or Gen-N could transform the...
The Futurists: Living Futures with Brian Solis, Brett King, and Robert Tercek - Brian Solis
How to Display Randomly Selected Posts (With and Without Plugin) – Growth Hacking Insights
All about Digital Marketing | Simply Explained
Welcome to the Novel Economy - Brian Solis
How To Write Ranking Content In 2023 | Koozai