WordPress plugin to insert code in header and footer

Have you ever been asked to add a code snippets section in the <header> or <footer> of your WordPress site? Such requests often arise when integrating with web services such as Google Analytics, Facebook Pixel, Google Search Console and others.

You can also encounter tutorials or guides for WordPress, which recommend to add some custom CSS code or Javascript in the header or footer of WordPress.

By default, WordPress does not provide the ability to insert code into the header / footer of your website. But there is a simple solution for beginners.

In this article we will show how easy it is to add code to header and footer in WordPress. Goal is safe to add code without editing the theme files of WordPress.

The best way to add code to the header and footer

There are three possible solutions:

  1. Manually editing the file header.php and footer.php your theme.
  2. Using the built-in header function and the footer of your theme.
  3. Using the plug-in.

The first option is not suitable for beginners, as it requires adding code to header / footer by editing the file header.php and footer.php manually.

Another disadvantage of using this method: your code will be deleted if you install the update for the theme.

The second option is the use of built-in function of your theme. Some WordPress themes such as Elegant Themes and Genesis Framework from StudioPress, offer built-in option to quickly add code and scripts in the header and footer of WordPress.

If you are using a theme with a built-in function that seems safe and easy solution. However, if you change your theme, all code snippets added to your website will disappear, including the test site in the console of the Google search site Analytics using Google Analytics and other services.

That is why we recommend users to use the third option, the plugin header and footer. This option today is the easiest and safest way to add code to the header and footer of WordPress.

With such tasks can cope a free plugin Insert Headers and Footers.

Here are some benefits of using the plugin Insert Headers and Footers:

1. Easy, fast and organized: it allows you to easily add codes in the header and footer of the website. In addition, it helps you to sort, since it stores all your codes for footer and header in one place.

2. Prevents mistakes: help prevent errors that can arise if you edit the theme files manually.

3. Do not refresh or change your theme: the plugin will save your header code and footer in a single place so you can update or change your theme without worrying about deleting code.

Adding code to the header and footer WordPress

The first thing you need to do is install and activate the plugin Insert Headers and Footers.

Once the plugin is activated, go to Settings”Insert header and footer of your admin panel. You will see two fields for adding code to the header and footer.

Just paste the code in one or in both fields. Then be sure to click the “Save” button that the code is preserved.

The plugin will now automatically load the code into the appropriate places on your WordPress site.

You can always edit and delete any code you don’t want to keep.

Deactivating the plugin will automatically remove the custom code that you added to the site.

If you inadvertently disable the plugin, the code will still be stored safely in your WordPress database. You can just reinstall or re-activate the plugin, and the code will again begin to appear.

Note. You may need to clear the cache in WordPress after you save the changes to the code appear correctly in the interface of your web site.

We noticed that the main reason why many budding web masters use the plugin Insert Headers and Footers is to add Google Analytics to your web site. To do this, we recommend you to use free plugin MonsterInsights. This is the best Google Analytics plugin for WordPress that helps to configure Google Analytics tracking and shows useful statistics on your WordPress dashboard.

Leave a Comment

Your email address will not be published. Required fields are marked *