Where Is The Head Tag In WordPress And Insert Code In It?

Your website may require you to insert code into the head section, and you may be unsure how to do so. Inserting codes may seem complicated, especially since WordPress does not make editing the head easy. Where is the head tag in WordPress and how you can add code in between head tags?

Between the <html> and <body> tags, you’ll find the <head> tag in the header.php file in your theme directory. Your WordPress theme’s header.php files can be edited to add additional code to it, either by using a plug-in, a built-in code feature, or manually.

I’ll show you how to get to the head tag in WordPress down below. In addition, I’ve clarified the two ways you can add code to it. Depending on your level of experience with WordPress, you can determine which method of inserting code is best for you.

Manually Insert Code Inside Head Tag In WordPress

Where Is The Head Tag In WordPress?

The header.php file in your theme directory contains the head tag. To access the header.php file, navigate to your WordPress dashboard and select the Appearance tab, then the Theme File Editor button.

When you click the Theme File Editor button, you’ll see a list of all the theme files that you can edit on the right side. The header.php file should open after you select it from the right sidebar.

You can see that the code file is now open, and you can find the header tag after the HTML tag in your header.php file, as shown in the image below.

For example, you can add a code for Google Analytics, Google Search Console, or Facebook Pixel in the <head> section. Custom CSS and JavaScript can also be inserted into the header. You need to also add the metadata to verify your website on the Google search console.

Where Is The Head Tag In WordPress

How To Add Code To Head Tag In WordPress?

You have two options when it comes to inserting code into the header section. Keep in mind that not all of these methods are appropriate for a beginner. So, if you are one, choose one that does not appear overly complicated to you.

Manually Insert Code Inside Head Tag In WordPress

Check the above image for more clarification and where you can find the head tag in the WordPress dashboard for your theme.

Once you have reached the above page, add the code you want to insert between the <head> and </head>. And then select the save button below to make sure the changes are applied to your theme files.

It is important to note that this is a manual method, and if you update your theme in the future, your header tag will be overridden by the default file, and any changes you make will be lost; therefore, it is recommended that you use a plugin to add header code in WordPress.

Insert Code Inside Head Tag In WordPress Using Plugin

Using a plugin to insert codes has many advantages. The first is speed and order. On the plus side, it allows you to centralize your codes.

It also prevents errors when editing your WordPress theme’s codes. Finally, if you upgrade or change themes, you won’t lose your code because the plugin saves it separately.

You have to first install and activate the Headers and Footers plugin. After that, go to ‘Settings’ and select ‘Insert Headers and Footers’.

Then there will be two boxes to enter the codes. Simply paste the required code and click ‘Save’. Put the code after the head tag and before the body tag. So you can be sure your code works.

How To Add Code To Head Tag In WordPress

The plugin will load the code in the appropriate places in your WordPress theme. You can also remove unnecessary code this way.

This is the simplest way to add header codes and is ideal for WordPress beginners. This is how I recommend you insert codes if you are a newbie.

Wrap Up

Using the tutorial above, you should be able to get the answer to the question “Where is the head tag in WordPress?” I’ve listed the two most important methods for adding or inserting code to your WordPress head tag.

The first method is to do it manually, which is not recommended because it is prone to errors, and if you accidentally mess up the code, it may be difficult to recover without a backup of your WordPress website.

That is why you should always use the plugin to securely place header code between your WordPress website’s head tags.

Please let me know in the comments section if you are still having problems, and I will be happy to assist you.

Further Read:

  1. Fix WordPress Revert To Previous Version Of Page
  2. Theme Editor Not Showing In WordPress: Quick Fix
  3. Is Grammarly Safe and Legit?
  4. How To Hide Page Title In WordPress Without Plugin