Headers and footers are important elements of a website’s design as they help create a consistent look and feel throughout the site. In WordPress, you can easily add headers and footers using code. In this article, we will guide on how to add header and footer using code in WordPress.
Guide In Add Header and Footer Using Code in WordPress
Log in to your WordPress dashboard and navigate to Appearance > Theme File Editor.

To add a header using code in WordPress, you need to open the header.php file in your theme editor and add the following code within the tags:
<header> <div class="logo"> <a href="<?php echo home_url(); ?>"> <?php bloginfo('name'); ?> </a> </div> <nav> <?php wp_nav_menu(); ?> </nav> </header>
This code includes a logo and navigation menu, which are common elements of a website’s header.
To add a footer using code in WordPress, you need to open the footer.php file in your theme editor and add the following code within the
tags:
<footer> <div class="copyright"> © <?php echo date('Y'); ?> <?php bloginfo('name'); ?> </div> <div class="social-media"> <a href="#" class="facebook">Facebook</a> <a href="#" class="twitter">Twitter</a> <a href="#" class="instagram">Instagram</a> </div> </footer>
This code includes a copyright statement and social media icons, which are common elements of a website’s footer.
Save the changes by clicking on the “Update File” button at the bottom of the screen.

View your website to ensure that the header or footer has been added successfully.
Add Header And Footer Using Code In WordPress FAQ
Here are the most common questions about adding header and footer using code in WordPress.
You can add any type of code, such as HTML, CSS, JavaScript, or PHP code to the header or footer in WordPress.
Yes, you can add different headers and footers to different pages in WordPress using various plugins available.
If you accidentally delete the header or footer file, you can restore it from a backup or contact your web hosting provider for assistance. If you want to remove header, click this.
Yes, you can add a header or footer to a specific post or page in WordPress using various plugins available.