Skip to main content
How to Enable Pinch to Zoom on Mobile Devices

Learn how to adjust your site's settings and implement necessary code changes to ensure that users can zoom in on mobile devices.

Updated over 4 months ago

Enhancing the user experience on mobile devices often involves enabling intuitive gestures like pinch-to-zoom, which allows users to view and interact with your content easily.

In this article, we will guide you through the process of enabling pinch-to-zoom on mobile devices for your website.

Using a Child theme

  1. Install and activate a Child theme

  2. Go to WordPress Dashboard β†’ Appearance β†’ Theme File Editor

  3. Open the functions.php file

  4. Add this PHP code below the existing code

    function remove_my_action() {
    remove_action('wp_head', 'et_add_viewport_meta');
    }
    function dt_et_add_viewport_meta(){
    echo '<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=5.0, user-scalable=1, viewport-fit=cover" />';
    }
    add_action( 'init', 'remove_my_action');
    add_action( 'wp_head', 'dt_et_add_viewport_meta' );

  5. Save your changes

Using the Code Snippets plugin

  1. Install and activate the Code Snippets plugin

  2. Create a new PHP snippet

  3. Add this PHP code:

    function remove_my_action() {
    remove_action('wp_head', 'et_add_viewport_meta');
    }
    function dt_et_add_viewport_meta(){
    echo '<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=5.0, user-scalable=1, viewport-fit=cover" />';
    }
    add_action( 'init', 'remove_my_action');
    add_action( 'wp_head', 'dt_et_add_viewport_meta' );

  4. Click on the Save Changes and Activate button

Note: Use one of the available methods that suits your case:

  • Use the first method if you already have a child theme enabled and active.

  • Use the second method if you don't have an active Child theme.

Did this answer your question?