Skip to content

Instantly share code, notes, and snippets.

@Garconis
Created September 25, 2017 15:05
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save Garconis/34b6be24ee644c024663ef1d2e11e2bb to your computer and use it in GitHub Desktop.
Save Garconis/34b6be24ee644c024663ef1d2e11e2bb to your computer and use it in GitHub Desktop.
Divi | Add pinch and zoom (user scalable) to mobile viewport meta
<?php
// Removes et_add_viewport_meta from the wp_head phase
function remove_divi_actions() {
remove_action( 'wp_head', 'et_add_viewport_meta' );
}
// Call 'remove_divi_actions' during WP initialization
add_action('init','remove_divi_actions');
// add ability to pinch and zoom
function et_new_viewport_meta(){
echo '<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=2.0, user-scalable=1" />';
}
add_action( 'wp_head', 'et_new_viewport_meta', 15 );
@B-Hard
Copy link

B-Hard commented Oct 2, 2017

Thanks! Worked great for me!

@kwrom
Copy link

kwrom commented Jun 29, 2018

Sorry for posting a stupid question - but do I paste this code in my child theme's functions.php file? And then I'm good to go?

@Garconis
Copy link
Author

Garconis commented Dec 1, 2018

Yes, likely without the opening php tag.

@ffot
Copy link

ffot commented Aug 27, 2020

Brilliant! Thank you Jon. Just spent a morning trying different variations on this but this one works and Googles Lighthouse loves it. Finally got a 100 score for Accessibility. My one question what purpose does the 15 serve on the last line?

@Kootenay-Girl
Copy link

Hello. I added this code to my functions.php and it worked great for accessibility but now I am getting warnings for SEO and performance that say there is no tag found. Any suggestions?

@Glinkfr
Copy link

Glinkfr commented Feb 15, 2023

Thanks! That improve my Accessibility's score in PageSpeed Insights

@dinhopereira
Copy link

Hello, i'm using Divi Extra, after put the code on functions.php, i found two metas on code:

and

Any suggestions ?

@Glinkfr
Copy link

Glinkfr commented Sep 8, 2023

Hello, i'm using Divi Extra, after put the code on functions.php, i found two metas on code:

and
Any suggestions ?
Use this : https://gist.github.com/Glinkfr/b120cdf4a715846342b616abe4fe7a19

@dinhopereira
Copy link

Hello, i'm using Divi Extra, after put the code on functions.php, i found two metas on code:
and
Any suggestions ?
Use this : https://gist.github.com/Glinkfr/b120cdf4a715846342b616abe4fe7a19

Perfect! tks :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment