• exitoconmujeres

    (@exitoconmujeres)


    I can′t resolve the problem of the missing viewport tag on my page.

    I get these lighthouse messages for all my pages
    – No <meta name="viewport"> tag found
    – Text is illegible because there’s no viewport meta tag optimized for mobile screens.
    – Tap targets are too small because there’s no viewport meta tag optimized for mobile screens

    I am far of beeing an expert with wordpress. But I tried to resolve the problem with inserting meta tags with the “code snippets” plugin or also to the “wp-blog-header.php” on my ftp.

    I added and saved the different tags, checked in lighthouse if it works. But no matter which code i tried, lighthouse is always saying that there is no viewport tag.

    I am really stucked right now. i would apreciate some help.

    Here are some of the tags I tried:

    {
    ?>
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <?php
    };
    
    add_action( 'wp_head', function () { ?>
    
    	<!meta name="viewport" content="width=device-width, initial-scale=1">
    
    <?php } );
    
    add_action('wp_head', 'your_function_name');
    function your_function_name(){
    ?>
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <?php
    };
    
    <!DOCTYPE html>
    <html lang="en">
      <head>
        …
        <meta name="viewport" content="width=device-width, initial-scale=1">
        …
      </head>

    The page I need help with: [log in to see the link]

Viewing 4 replies - 1 through 4 (of 4 total)
  • Joy

    (@joyously)

    The viewport meta tag should be in the front end of your site, which means it belongs in the theme (or child theme) or a plugin that puts it in the front end.
    Where is this wp-blog-header.php file? (Don’t change WordPress files; the changes get overwritten with new releases.)

    Thread Starter exitoconmujeres

    (@exitoconmujeres)

    Thank so much for your response Joy. The wp-blog-header file is in the filemanager ftp. But in the plugin “code snippets” I have the option to just run the tag in the frontend.

    I have tried it now with the 2 following codes. But still lighthouse and search console tell me the error concerning the missing viewport…

    {
    ?>
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <?php
    };
    
    <?php } );
    
    add_action( 'wp_head', function () { ?>
    
    	<!meta name="viewport" content="width=device-width, initial-scale=1">
    
    <?php } );
    Joy

    (@joyously)

    I don’t know the syntax that your code snippet plugin expects, but what you’ve put here is a mess.
    What are the braces for on the first one? And how do you expect it to come out in the head section?

    The second one also has funky braces and parentheses at the beginning, and the meta tag has a ! which isn’t right.

    You might want to ask at the support forum for your snippet plugin, for the correct syntax expected in the snippet. Depending on when the snippet is done, the wp_head might be already past.

    Thread Starter exitoconmujeres

    (@exitoconmujeres)

    I have no idea about coding Joy. Just searched a lot in google and these are the codes that I have found when somebody had a similar problem.

    But thanks anyway for your help!

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Lighthouse – No “ “ tag found’ is closed to new replies.