Skip to main content
All CollectionsSupplementary GuidesWordPressGeneral
Adding Code to WordPress Headers and Footers
Adding Code to WordPress Headers and Footers
Rapyd Team avatar
Written by Rapyd Team
Updated over a week ago

This document provides instructions on adding code to a WordPress website's headers and footers. Manipulating headers and footers can have many applications, such as adding custom scripts, tracking codes, stylesheets, or adding meta tags.

It is always recommended to backup your files and test any changes in a development or staging environment before applying them to a live website.


Using a Theme's Customization Options

Many WordPress themes provide built-in customization options to add code to the headers and footers. Follow these steps to add code using the theme's options:

  • Log in to your WordPress admin dashboard. Then, navigate to Appearance and click on Editor as shown below.

  • Look for “Template Parts” as shown below.

  • Click on Footer as shown below and click on Edit.

  • Now click on the plus sign and look for the code widget as shown below.

  • You can now add code in the section as shown below.

  • Likewise, you can edit code in the Header section in the same way as shown for the Footer section.

  • When choosing a widget to add code, you choose to add various types of codes such as Custom HTML, and ShortCode as shown below.

Note: The availability and location of customization options may vary depending on the theme you are using. Refer to your theme's documentation or contact the theme developer for specific instructions.

Using a Plugin

If you prefer not to modify theme files as shown above, but you want to directly manage the codes then you will need to install a plugin to add code to the headers and footers of your WordPress website. Here's how:

  • Log in to your WordPress admin dashboard.

  • Navigate to Plugins and click on Add New.

  • In the search bar, enter a relevant search term such as "header footer code" or "insert code."

  • Browse through the available plugins and choose one that suits your needs. In our case, we have chosen the plugin Header Footer Code Manager as shown below.

  • Once the plugin is installed you will find the 2 options under the Tools section: Theme File Editor and Plugin File Editor

  • Choose any one of the options: Theme File Editor or Plugin File Editor for editing the code of your Theme or Plugin as needed.

Note: This is how code is commonly accessed. It is recommended to be very careful when editing code especially if it is a plugin built by a different organization.

Conclusion

By adding custom code to the headers and footers, you can enhance the functionality and appearance of your WordPress site. This allows you to incorporate scripts, stylesheets, tracking codes, or meta tags seamlessly into your website's structure.

Remember to exercise caution when modifying the headers and footers, as improper implementation may lead to unintended consequences or compatibility issues. It is always recommended to backup your files and test any changes in a development or staging environment before applying them to a live website.

Did this answer your question?