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

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

How to Insert Code in WordPress?

There are various conditions for WordPress for adding the code. So we will discuss all the methods?

  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 by two methods.

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

First Method:

Add Custom or Tracking Code into 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

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

Insert Headers and Footers 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 to the head section of your website.

After putting the code then Save this Code.

Scripts in Header

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

Scripts in Footer

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

Second Method:

Insert Custom or Tracking Code to WordPress Headers and Footers without Plugin:

You should use this method if you do not want to use the plugin for inserting the code.

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

Theme Editor

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

Header file

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

Head-tags

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 the Theme Files, Open Footer ( footer.php) file.

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

body-tag

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

Second Condition:

How to Add HTML Code to WordPress Post & Pages?

Case 1:

If you want to insert HTML code into WordPress Posts & Pages then follow this guide. This will remain the 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

Step 2: After clicking on the 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

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

HTML-Box

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

So this will successfully insert 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 options.

  1. Visual Editor
  2. HTML Editor

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

HTML Editor

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

Visual-Editor

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

Conclusion:

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

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

If you have liked this article then please share it and like our Facebook Page.

We love to hear from you about which method do you want to use. Please let us know in the comment section.

Read More:

How to Add Google Analytics to WordPress?

How to Install WordPress in cPanel?

Last Modified on by VISAL TYAGI

Share this post

Share on facebook
Facebook
Share on twitter
Twitter
Share on linkedin
LinkedIn
Share on pinterest
Pinterest

5 thoughts on “How to Add Code in WordPress Headers & Footers and Post & Pages?”

  1. It’s actually a cool and useful piece of information. I’m
    glad that you just shared this useful info with us.
    Please keep us informed like this. Thanks for sharing.

    Reply
  2. Why viewers still make use of to read news papers when in this technological world the whole thing is existing on web?

    Reply

Leave a Comment

Receive The Latest Traffic Tips

30 Proven Ways
To
Increase Website Traffic

Discover the Secrets – 15000 Words

5 Shares
Share3
Tweet
Pin2
Share
Share