[Support request] On Mobile How to Force specific page to Desktop Mode

Home Forums Support [Support request] On Mobile How to Force specific page to Desktop Mode

Home Forums Support On Mobile How to Force specific page to Desktop Mode

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #2324512
    Maggie

    Hi team,

    Example when I’am on mobile, how to force specific page to Desktop Mode. Is this possible, and how?

    Thanks.

    #2324548
    David
    Staff
    Customer Support

    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.

    #2325894
    Maggie

    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.

    #2326181
    David
    Staff
    Customer Support

    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;
    } );
    #2326637
    Maggie

    Thanks David it works.

    #2326850
    David
    Staff
    Customer Support

    Glad to hear that !

Viewing 6 posts - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.