Latest Headlines

How to Add Code in WordPress Headers & Footers and Post & Pages?

If you are a marketer or developer then you have need to insert various types of code in your WordPress website or blog. So here we will discuss the various methods for How to Add Code in WordPress.

How to Add or Insert Code in WordPress?

There are various conditions for WordPress for adding the code. So we will discuss all and tell you about how you can add the code?

  1. Insert any type of custom or tracking code in Header & Footer.
  2. Add HTML Code in WordPress Posts and Pages.

First Condition:

How to Insert Custom or Tracking Code into WordPress Headers and Footers?

You can add custom or tracking code into WordPress by two methods.

  1. You can add using the plugin.
  2. Insert Manually in WordPress.

First Method:

How to Insert Custom or Tracking Code in WordPress Headers and Footers using Plugin?

Step 1: Go to your WordPress admin dashboard. Install the WordPress Plugin name Insert Headers and Footers Plugin.

Insert Headers and Footers
Insert Headers and Footers

Step 2: You will find the Insert Headers and Footers in Settings in WordPress Admin Dashboard.

Insert Headers and Footer in Settings
Insert Headers and Footer in Settings

Step 3: If you want to paste the tracking or custom code into the Header of WordPress then put the code into Scripts in Header. This will add your code in the head section of your website.

After putting the code then Save this Code.

Scripts in Header
Scripts in Header

If you want to paste the code into footer of your WordPress website. Paste your tracking or custom code into Scripts in Footer. Save the code.

Scripts in Footer
Scripts in Footer

This is the first method for putting the code into WordPress Headers and Footers.

Second Method:

How to Insert Custom or Tracking Code in WordPress Headers and Footers without Plugin?

If you want to put your code into Headers section of WordPress website without plugin then follow this guide.

Step 1: Go to Appearance section and Click Editor or Theme Editor.

Appearance
Appearance

Step 2: In the right side, you will see Theme Files. Open Header file which is in form of header.php file.

Header file
Header file

So put your code into head section between <head></head> tags. After put your code then save your header.php file.

So your custom or tracking code will be successfully inserted.

If you want to put your custom or tracking code into the WordPress Footer then follow this guide.

Step 1: Go to Appearance, Open Theme Editor.

Step 2: In Theme Files, Open Footer ( footer.php) file.

 Footer File
Footer File

Step 3: Put your code before </body> tag in the footer.php file. Your code will be successfully added. Save the header.php file.

body tag
body tag

So this is method which will help you to insert your custom or tracking code into WordPress Headers and Footers manually.

Note: If you want to put your code after <body> tag then the <body> tag will be find in header.php file.

Second Condition:

How to Add HTML Code in WordPress Post & Pages?

Case 1:

If you want to insert HTML code into WordPress Posts & Pages then follow this guide. This will remain same for posts and pages.

Step 1: If you are using Gutenberg editor then you will see a + ( Plus ) sign in the upper side. Click on the Plus sign.

Plus Sign
Plus Sign

Step 2: After clicking on plus sign, you will see many options like

  • Most Used
  • Inline Elements
  • Common Blocks
  • Formatting
  • Layout Elements
  • Widgets
  • Embeds
  • Yoast Structured Data blocks

Click on Formatting for adding the code. In Formatting, you will see Custom HTML. Click on Custom HTML.

Formatting
Formatting

When you will click on Custom HTML then you will see an HTML Box like this. Paste your HTML Code into HTML.

Example: We put a code into HTML.

<h5>This is our first headings</h5>

In Preview, it will show the result like this.

HTML Preview
HTML Preview

So this will successfully added your HTML Code into WordPress posts and pages like this in Gutenberg.

Case 2:

If you are using Classic Editor and want to paste the HTML Code then follow this guide.

Step 1: Go to Classic Editor and You will see two option.

  1. Visual Editor
  2. HTML Editor

Choose HTML Editor. Paste your HTML Code. Paste your code between paragraph tags.

HTML Editor
HTML Editor

After pasting the code, move on Visual Editor. It will show your HTML result like this.

So you can insert your HTML Code into Classic Editor like this. So this is the complete guide about How to Add Code into WordPress Posts & Pages.

Conclusion:

With the help of this guide, you can easily add your Custom or HTML Code into WordPress Headers & Footers and Post & Pages easily. You can put your code with the help of plugin or without plugin.

You can apply any of these methods for your WordPress website or blog.