Archived topic
Filter not working ? (generate_meta_viewport)
3 replies · Started by Sjoerd on December 22, 2020
Hi there,
I am trying to change the <meta name="viewport">
I found there is a filter in GeneratePress that does this (generate_meta_viewport), but I can't seem to get it working.
Current code:
add_filter( 'generate_meta_viewport', 'my_meta_viewport' );
function my_meta_viewport() {
return 'width=device-width, initial-scale=1, maximum-scale=1, user-scalable=0';
}
I also noticed there is a function now in Wordpress itself since 5.5.0.
https://developer.wordpress.org/reference/functions/wp_admin_viewport_meta/
But I can't seem to get that one working either.
I am using Code Snippets to add the filter and I have it set to frontend only, but even when running it everywhere it doesn't work.
Hope someone can help me out.
Hi there,
you have to declare the full HTML using that filter - see here for an example:
https://generatepress.com/forums/topic/meta-viewport-not-working/#post-1551645
Ahh makes sense! Thanks David, it worked :-)
You're welcome