How to add IE EDGE header to all pages (including wp-login)

We need to add `<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">` to our sites as IE11 is defaulting to an older version.

I think this article but the second element in regard to the wp-login page doesn't work...
https://www.itsupportguides.com/knowledge-base/wordpress/wordpress-how-to-add-ie-edge-header-to-all-pages-including-wp-login/

  • Adam Czajczyk

    Hello uol

    I hope you're well today and thank you for your question!

    I have tested the code from the article and it seems to be sending proper headers on my end. I understand that the first part - for the front-end - is working fine for you as well, just the "wp-login.php" part is not, right?

    Can you tell me please where/how did you add that second part of the code?

    Also, try removing "conditionals" from the code (just for testing) so instead of these three lines

    if ( 'wp-login.php' === $GLOBALS['pagenow'] && ! headers_sent() && isset($_SERVER['HTTP_USER_AGENT']) && (strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== false) ) {
             header( 'X-UA-Compatible: IE=edge,chrome=1' );
       }

    try just

    header( 'X-UA-Compatible: IE=edge,chrome=1' );

    while rest of the code is the same.

    Let me know about both code placement and if the changed code works, please.

    Kind regards,
    Adam

  • Adam Czajczyk

    Hello uol

    Thanks for your reply.

    The notice suggests that this might be related to the settings of "globals" - in PHP globals can be (and often are) disabled and in that case that entire (if.... conditional statement) would be omitted.

    IN this case, try following what I suggested before - removing entire "if..." statement (see my previous post).

    As for checking headers in IE. Yes, that's doable. In Internet Explorer 11 you can do it like this:

    - hit F12 once the page is load (it will open browser console)
    - switch to "Network" tab in browser console
    - there should be a "content type" option so use it to make sure that "Documents" is selected
    - on a list the 1st or 2nd position should point (see the URL) to the loaded page (it will probably be something like just "/" or with some attributes like "?redirect_to=":wink:
    - click on it and you should see headers in the panel on the right

    I've attached a screenshot for you but please note that it's in Polish (unfortunately, I cannot switch language in IE11 (unlike in Chrome or Firefox) as it takes language settings from the OS - so consider it please a visual indication of what you should see rather than a detailed "visual guide" (it's an example on msn site but the rule is the same).

    Best regards,
    Adam

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.