How to Edit The WordPress Header and Footer Files

modify-themeThere are times when you will want to customize the header or footer of your WordPress website by adding or removing items from those areas.

For example, common requirements for many site owners are:

  • Remove powered by WordPress from each page.
  • Add a copyright notice to the bottom of each page.
  • Remove the site Title and Tagline from each page.
  • Add Advertising banners to the top of bottom
  • Add newsletter opt-in forms to the top of bottom.

Adding and removing content to or from the bottom (footer) or top (header) of a WordPress site is relatively easy due to the way that WordPress is structured.

In this tutorial we look at the basic structure of WordPress pages and sites, and then we look at how to edit the WordPress footer (footer.php file) and header (header.php) files.

Basic WordPress Site – Page/Post Structure.

The web page layout will change depending on the theme.

That is; some pages will have a single column, some two columns, some will have the content on the left, others will have the content on the right etc .

Regardless of this WordPress considers all web pages and posts to consist of 4 distinct blocks, as shown in the diagram below:

wordpress-page-structure

These blocks are contained in several files but all themes use a single file for the footer block (footer.php file) and for the header block (header.php file).

WordPress allows you to edit theme files using the WordPress Admin console.

You can view and edit these files by going to Appearance>Editor

edit-theme-files

 

The files for the current theme are displayed in the right and the content of the style sheet is open for editing in the main windows.

To edit the header or footer files click on the theme footer or theme header link.

To edit the header or footer files of another theme you will first need to select the theme using the drop down arrow.edit-header-footer-files

You may notice in the above screen shot I am using a child theme.

This is a very important point to consider.

If I was to edit the actual 2012 Theme file (default WordPress theme) then when I updated WordPress the themes files would be overwritten, and my changes would disappear.

Therefore the best approach is to use a child theme.

 Editing the Header and Footer Files Steps

To modify either the header or footer we will use a child theme.

The process is simple, and is as follows.

  • Create the child theme. See creating child themes.
  • Copy the header.php and footer.php files from the parent theme into the child theme folder.
  • Edit the header.php and footer.php files as required.

Here is what the child theme folder should look like.

child-theme-folder-contents

Here is video showing how to edit the header.php file.

Here is video show how to edit the footer.php file.

In the video we replace the default powered by WordPress link with a copyright notice.

Here is the copyright text I used

&copy;Copyright swcpublish 2009 to <?php echo date('Y'); ?> buildingwebsites.com

Note: Security changes in WordPress may mean that you changes you make are scanned for errors.

Common Questions and Answers

Q- Where are the footer.php and header.php files?

A- They are located under the theme directory which itself is under the wo_contents folder as shown below:
wordpress-content-directory

Q- Why do we use child theme to modify the header and footer files?

A- Because if we upgrade the parent theme it doesn’t affect our changes.


Q- What happens to header and footer files of the parent theme?

A- Nothing they are not used?


Q- What happens when I upgrade the parent theme?

A- The Parent theme files are upgraded, but it doesn’t affect the child theme.


Q- Do I need to copy both the header.php and footer.php files to my child theme folder?

A- You only need to copy the files that you want to change!

Q- How do I copy the header.php and footer.php files to my child theme on my host?

A- you will need to use FTP or Web FTP -See upoading webpages using ftp.

Related Articles and Resources:

Save

Save