Archived topic
On Mobile How to Force specific page to Desktop Mode
5 replies · Started by Maggie on August 26, 2022
Hi team,
Example when I'am on mobile, how to force specific page to Desktop Mode. Is this possible, and how?
Thanks.
Hi there,
you can use the generate_meta_viewport filter in a PHP Snippet:
https://docs.generatepress.com/article/generate_meta_viewport/
For example:
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;
} );
This will set the viewport to a width of 1024 on all devices for the Home Page.
If you can share a link to the page you want to apply it to, i can update the code to work for it.
Here's the link https://purlp.com/watch-pba-basketball/.
This is what is do, but its not working. please give me a detail instruction.

Thanks.
Ok, so that is a single post, so you can use the postID to specify that post.
Change the PHP Snippet to:
add_filter( 'generate_meta_viewport', function($meta) {
$meta = '<meta name="viewport" content="width=device-width, initial-scale=1">';
if ( is_single(11958) ) {
$meta = '<meta name="viewport" content="width=1024">';
}
return $meta;
} );
Thanks David it works.
Glad to hear that !