So I'm pretty new at Wordpress development, and I'm a little confused by one thing. After going through and finishing my navigation in my header.php file, I went over to my template for the home page I'm working on. My question is: since the "body" tag is the only place you can write that actually shows up in the browser ("header" tags are for meta data etc), can I have more than one body tag? I read a little into html 5, and it seems there are more tags than just "body" now, but what's the best way to do that? I already have my menus wrapped in and what do I do with the footer, etc? Thanks for any help.
2 Answers
Structure your theme so you start the <body>
in the header and you close the </body>
in the footer (same thing for the <html>
tag):
header.php
<html>
...header content
<body> <!--- body is started in the header, used on every page -->
index.php, page.php, single.php, home.php - etc
...content
footer.php
...footer content
</body> <!-- body is closed in the footer, also used on every page -->
</html>
-
Thank you so much! That was so confusing to me. Lol. I knew you couldn't have more than one body tag, so I just didn't get how WordPress could split it up. Makes sense though. :) Commented Dec 27, 2016 at 16:16
-
This may help you regarding having two body tags. is_front_page() will help you to echo body tag conditionally... either in header/footer.