Did you know that you can use WordPress built-in “mobile detect” function
wp_is_mobile to create a simple shortcode that can hide certain parts of your content from mobile visitors and-/or desktop visitors.
wp_is_mobile function returns true when your site is viewed from a mobile browser. Using this function you can create adaptive-/responsive wordpress themes based on visitor device. This snippet will allow you to use shotcodes the [desktoponly] desktop content [/desktoponly] or [mobileonly] mobile content [/mobileonly] to determine what content should be returned to the visitor.
Add this code to your
|Tested with WordPress v. 4.8|
|Last Modified: 15.05.2018|
|Last Reviewed: 15.05.2018|
How to display content for mobile- or desktop only using WordPress “wp_is_mobile”.
3.9 (77.5%) 8 votes
Please report broken snippets.