wordpress get_header() on a page template getting the head content inside of the body tag

Question

I am having trouble with my WordPress template page. When calling get_header() in the template page, the content of the head is appearing inside the body tag and causing trouble. I couldn’t find a solution for this.

This is what I mean :
inspect element

page template :

<?php
  /*
  * Template Name: sub services
  */

  get_header();
 ?>

 <h1>sub page</h1>

 <?php
   get_footer();
 ?>

header.php :

<!DOCTYPE html>
   <html <?php language_attributes(); ?>>

   <head>
     <meta charset="<?php bloginfo('charset'); ?>">
     <?php wp_title();?>
     <link rel="icon" type="image/png" href="/favicon.png">
     <link href="https://fonts.googleapis.com/css2?family=Lemonada:wghtOne Page Zen&display=swap" rel="stylesheet">
     <script src="https://kit.fontawesome.com/90928eb6b7.js" crossorigin="anonymous"></script>
     <?php wp_head(); ?>
   </head>

   <body id="theme-body" <?php body_class(); ?>>
     <header>
       <h1>Main Header</h1>
     </header>

and I have added a page in wordpress admin and linked it to the template.

wordpress add page

Everything works fine except that the content of the head is in the body tag. when calling get_header(). In the template.php I have checked my error log and its fine. I dont know what is causing this problem or what I’m doing something wrong.

0
user198136 2 months 0 Answers 8 views 0

Leave an answer