# Allow Pinch-to-Zoom on Mobile

> Removes maximum-scale and user-scalable=no from the page's viewport tag when a theme or plugin adds them, so visitors can zoom in on phones as WCAG requires.

- Type: PHP
- Runs: Frontend only
- Category: [Accessibility](https://wpide.com/library/category/accessibility/)
- Tags: mobile, zoom, viewport
- Author: WPIDE Team
- Installs: 0
- Updated: 2026-10-28
- Page: https://wpide.com/library/a11y-allow-pinch-zoom/

## Code

```php
add_action( 'wp_head', function () {
    ?>
<script>
(function () {
    function fix() {
        document.querySelectorAll('meta[name="viewport"]').forEach(function (meta) {
            var content = meta.getAttribute('content') || '';
            var cleaned = content.split(',').map(function (part) { return part.trim(); }).filter(function (part) {
                return part && !/^(maximum-scale|user-scalable)\s*=/i.test(part);
            }).join(', ');
            if (cleaned !== content) { meta.setAttribute('content', cleaned); }
        });
    }
    fix();
    document.addEventListener('DOMContentLoaded', fix);
})();
</script>
    <?php
}, 99 );
```

## Notes

Runs early in the page head and only touches the viewport meta tag.

## How to use it

Install the free WPIDE plugin (https://wordpress.org/plugins/wpide/), find "Allow Pinch-to-Zoom on Mobile" in its snippet library and add it in one click; or create a new PHP snippet in WPIDE (or any code snippets plugin) and paste the code above. More snippets: https://wpide.com/library/
