[Resolved] Filter not working ? (generate_meta_viewport)

Home Forums Support [Resolved] Filter not working ? (generate_meta_viewport)

Home Forums Support Filter not working ? (generate_meta_viewport)

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #1590499
    Sjoerd

    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.

    #1590530
    David
    Staff
    Customer Support

    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

    #1590960
    Sjoerd

    Ahh makes sense! Thanks David, it worked 🙂

    #1591035
    David
    Staff
    Customer Support

    You’re welcome

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