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?
- Insert any type of custom or tracking code in Header & Footer.
- Add HTML Code in WordPress Posts and Pages.
How to Insert Custom or Tracking Code into WordPress Headers and Footers?
You can add custom or tracking code into WordPress by two methods.
- You can add using the plugin.
- Insert Manually in WordPress.
How to Insert Custom or Tracking Code in WordPress Headers and Footers using Plugin?
Step 2: You will find the Insert Headers and Footers in Settings in WordPress Admin Dashboard.
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.
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.
This is the first method for putting the code into WordPress Headers and Footers.
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.
Step 2: In the right side, you will see Theme Files. Open Header file which is in form of header.php 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.
Step 3: Put your code before </body> tag in the footer.php file. Your code will be successfully added. Save the header.php file.
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.
How to Add HTML Code in WordPress Post & Pages?
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.
Step 2: After clicking on plus sign, you will see many options like
- Most Used
- Inline Elements
- Common Blocks
- Layout Elements
- Yoast Structured Data blocks
Click on Formatting for adding the code. In Formatting, you will see Custom HTML. Click on Custom HTML.
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.
So this will successfully added your HTML Code into WordPress posts and pages like this in Gutenberg.
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.
- Visual Editor
- HTML Editor
Choose HTML Editor. Paste your HTML Code. Paste your code between paragraph tags.
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.
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.