Connect with us
Padiwise Banner


How to Display Content for Mobile or Desktop Only Using WordPress



How to Display Content for Mobile or Desktop Only Using WordPress

This WordPress snippet will 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.

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. The 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.

Method 1 instructions
Simply use IF conditions in your templates.

/* Ofofonobs Developer... */<?php if( wp_is_mobile()){ ?> 
<span>mobile stuff goes here</span>
<?php } else { ?> 
<span>desktop stuff goes here</span>
<?php } ?>

Method 2 instructions
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 functions.php

/* Ofofonobs Developer... */<?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;


Disclaimer:  We sell any type of script/themes/plugins, we also offer web design/developement, graphics design, SEO, Social media followers, VTU Platform and more. visit our contact page to get in touch with us or WhatsApp (+234) 08114313795. data
Click to comment

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.


Entertainment4 weeks ago

John Okafor Mr. Ibu Biography: Net Worth, Family, Movies And More

John Okafor Mr. Ibu Biography & Net Worth ( Fully Updated ) John Okafor is more commonly known as Mr....

Entertainment4 weeks ago

Brely Evans Biography: Husband, Books, Age, Career

Brely Evans, who was born on December 9, 1972, in Oakland, California, and raised in Milwaukee, Wisconsin, is a multi-talented...

Entertainment4 weeks ago

Meet Gbadebo Rhodes Vivour, The Labour Party Governorship Candidate In Lagos State 

Gbadebo Rhodes Vivour profile Gbadebo Chinedu Rhodes-Vivour, popularly known as GRV, is a Nigerian architect, activist, and politician born on...

Entertainment4 weeks ago

Yinka Okeleye Biography: Age, State Of Origin, Education, Wife, Songs, Girlfriend

Adeyinka Okeleye is a talented Gospel singer and worship leader from Ogun State, Nigeria. He currently serves as the Music...

Entertainment4 weeks ago

Sunmisola Agbebi Biography: Age, Songs, Family, Boyfriend, Net worth, Education

Sunmisola Elizabeth Agbebi is a talented Nigerian gospel singer with a distinct and energetic style. She is 24 years old...

Entertainment4 weeks ago

Meet Beatrice Itubo, The LP Governorship Candidate In Rivers State

Beatrice Itubo, the Labour Party gubernatorial candidate for the 2023 governorship election in Rivers State was born on Sunday, June...

Entertainment4 weeks ago

Meet Somachi Chris Asoluka , The New CEO Of Tony Elumelu Foundation

Somachi Chris Asoluka was announced as the new Chief Executive Officer of Tony Elumelu Foundation on January 9, 2023. She...

Entertainment4 weeks ago

Tasha Cobbs Leonard Christmas Family Photos With Husband And Children

It’s December 26 and everyone especially married people is sharing their beautiful family photos with matching pajamas . Well, famous...

Entertainment4 weeks ago


Deborah Paul Enenche was born on 28 of March 1995 2. She is a Nigerian top-rated gospel singer and first...

Entertainment4 weeks ago

Lillian Mutambo Biography: Age, Investment , Marriage And More

Lillian Mutambo is a 39 year -old Zambian social worker and youtuber based in the United Kingdom. Music Career Lily...