I’ve been trying to fix the issue where wp_head loads in the body tag in wordpress, and I’ve discovered that when I look at the page source, an extra HTML block appears before the code from my header.php file.
Here’s what I’ve tried:
- Setting wp_debug to true
- ensuring that charset is UTF-8
- removing all text before the beginning of !DOCTYPE
- check for missing closing tags
This is my header.php
file
Here is the output source:
You can see that my code is being rendered correctly.. but why am I getting a HTML block at the start of the document?? Any help would be amazing. Thanks so much
1 Answer
I am really not sure what’s causing this. Can you try with a minimal content in header.php
? Something like this and see if the problem occurs?
<!doctype html>
<html <?php language_attributes(); ?>>
<head>
<meta charset="<?php bloginfo( 'charset' ); ?>">
<meta name="viewport" content="width=device-width, initial-scale=1">
<?php wp_head(); ?>
</head>
<body <?php body_class(); ?>>
And, meta tags doesn’t support class
attributes like you have in line 11.