A Safe and Easy Way to Add Code to A WordPress Website’s Header or Footer

A Safe and Easy Way to Add Code to A WordPress Website’s Header or Footer

There may be occasions when you need to customize your WordPress website, and the only option is to edit the underlying code of the theme you are using. The purpose of this customization might be to change the appearance of your website, or perhaps alter the way it functions. Generally speaking, keeping your theme files untouched is a best practice since  updates and changes to your theme can overwrite your customizations. Thankfully, modern WordPress practices and a variety of plugins make it easy to customize your site safely and efficiently.

In these instances, you can simply open up the relevant theme files and make those changes directly from within your WordPress website. However, this isn’t an ideal approach for a number of reasons.

Changing themes, or even updating your theme when a new version is released, could overwrite your customizations and additions. Furthermore, if you make a mistake while editing those files, you could find it difficult to retrace your steps and undo those changes. Worst case scenario: you could get locked out of your website, making it very difficult to make any further changes.

Even if your changes are successful, there could come a time in the future where you, or someone else might want to review those changes or deactivate them.

So as you can see, there are a number of issues that can arise when directly editing the underlying files that make up your website. Thankfully, there is a handy plugin available which allows you to safely insert code into the header and footer of your website, while also giving you an easy way to deactivate that code in the future.

That plugin is called Header and Footer and it’s one that has been created by developer Stefano Lissa.

This free plugin allows you to add code and other content to your theme’s header and footer sections. This could include an analytics tracking code, custom PHP or JavaScript, and anything else that can enhance your website by being inserted into the header and footer sections.

If you are following a tutorial or documentation and you are instructed to edit your website’s header or footer, using this plugin gives you a safe way to do so.

As the Header and Footer plugin is free to use, it can be installed on your site directly from the WordPress plugin directory.

To do so, log into your site’s admin area (http://yoursite.com/wp-login.php) and then navigate to Plugins > Add New using the sidebar menu.

From the Add Plugins screen, enter ‘Header and Footer’ in the search field and then install the first item listed in the results.

Installation Steps:

  • Navigate to Plugins > Add New.
  • Search for ‘Header and Footer’.
  • Select ‘Install Now’ on the first result.
  • After installation, select ‘Activate’.
  • Once activated, you can access it from the Header and Footer item under Settings on the admin sidebar. The plugin interface is pretty straightforward, allowing you to easily paste your code snippets into the designated header or footer sections.

Once the plugin has been installed and activated, it can be accessed from the Header and Footer item under the Settings menu on the admin sidebar.

By selecting the appropriate tab, you can then write or paste your code snippet in the way that you want.

Header Footer Add Code

Now you’ve got an easy way to make additions to the underlying code of your website. This approach also gives you the ability to easily keep track of, and review your changes.

More information on using this plugin can be found in the Header and Footer section of the developer’s website.


This plugin gives you an easy-to-use interface for adding code to the header and footer sections of your WordPress website. Hopefully, you should now be able to customize your website with confidence, and add additional code snippets as needed.

If you are looking for a safe and easy way to add code snippets to the functions.php file without direct editing, the Code Snippets plugin is another excellent option. For more advanced customization, consider using child themes, which allow you to make extensive changes without affecting the original theme files.

If you have any questions about this plugin, or using WordPress in general, please leave a comment below.

Additional Resources 

For those eager to dive deeper into WordPress customization, here are some excellent resources:

Staying informed and continually learning will help you make the most of your WordPress website

New Posts in your inbox