Archived topic
Disable mobile View
3 replies · Started by Allen on April 23, 2021
hi
How can I disable mobile view? Forcing desktop view in mobile/tablets devices as shown in the screenshot below.
Can I still use this plugin or there is a better way?
https://wordpress.org/plugins/generate-disable-mobile/
Thanks
Hi there,
that plugin is old - i doubt it works today,
You can try this PHP Snippet to change the sites viewport meta to maintain desktop view:
add_filter( 'generate_meta_viewport', function() {
return '<meta name="viewport" content="width=1024">';
} );
Thanks David!
It's working well!
How can run this snippet in front page only?
Once visitor clicked on post's title then will go back to normal mobile view?
Thanks
Try this instead:
add_filter( 'generate_meta_viewport', function($meta) {
$meta = '<meta name="viewport" content="width=device-width, initial-scale=1">';
if ( is_front_page() && is_home() ) {
$meta = '<meta name="viewport" content="width=1024">';
}
return $meta;
} );