Shortcode to Hide WordPress Post Content on Mobile Devices

Hide WordPress Post Content

Checkout Shortcode to Hide WordPress Post Content on Mobile Devices.

If you are new to WordPress and want to hide some information on the mobile like you have a post which is too long and you don’t want it to be viewed on mobile then don’t worry; it is very easy to hide your post contents on mobile phones. In the following article, I explain you how can hide WordPress post content on mobile devices.

Hide WordPress Post Content on Mobile Devices

Just follow the simple code which is given below –

function not_mobile_shortcode($atts, $content = ”) {

if (wp_is_mobile() === true) {

$content = ”;

}

return $content;

}

add_shortcode(‘not_mobile’, ‘not_mobile_shortcode’);

You have to add the given code in your WordPress theme’s functions.php. This is the quickest method by which you can hide the long content. After that publish the post then open the browser on your mobile and see the post. You will not be able to see that post as it’s hidden on mobile devices.

Best AdSense Optimized WordPress Themes

Word Press Plugins to hide Contents

The method given above is just a simple coding method which does not require the plug-in but now we are going to describe the method for hiding the posted content with the help of plug-in.

Step 1: Go the control panel of your word press site then go to the Plugins option which is available on left hand side of the dashboard.

Step 2: Click on Add New button and then look for ‘WP Mobile Detect’. You need to install it from here. In case you don’t know anything about the WP Mobile Detect option then no need to worry. You can check all the details about the same by clicking Details Button. After that you will get the instant warning message.

The plugin will be installed.

This post was last modified on July 4, 2018 12:15 PM

Preethi Khetani: Preethi Khetani is a well known women Blogger from India. Apart from her contribution here, she writes for NowIamupdated.com and Advices Academy as well.