Adding Adsense code above the main content in your WordPress website theme is a great place for ads to blend in and look like its part of the post. It is not always good to just slap the Adsense ads directly into your posts and pages. Placing the Adsense code into the php code of your WordPress theme will enable the ads to show up on every page or post, depending where you place the code. In this tutorial I will show you how to insert the Adsense code above the main content in the Socrates WordPress theme, however the same steps can apply to other WordPress themes as well.
Insert Adsense code above the main content title in Socrates
Placing Adsense above the main content title in WordPress makes the ads look like a menu bar and they look like they belong there. Therefore when you go to an individual post page you will see the ads first and then the title of the post and then the content.
There are three main places where you can insert Adsense code above the main content title in Socrates, as with most other WordPress themes.
- In the Index.php
- In the post.php ( can also be named single.php or something similar)
- In the page.php
The index.php is the main page or front page of your WordPress website. The post.php is the individual post and the page.php is the individual pages. Therefore if you place the Adsense code into the index.php only then the ads will show on the front page but not in the posts and pages.
Where do I insert Adsense code above the main content?
1. Go to your WordPress dashboard.
2. In the left menu find the Appearance menu.
3. Click on the drop down arrow to see the menu. See the screen shot below.
4. Press on the Editor link.
5. Now you will see a list of page templates to choose from on the far right.
6. Choose the template you want to add the code to.
7. Click on the template and the code will come into the box to edit.
Now to add the code above the main content title:
1. Go to the index.php and find
2. Above this is where you put your code.
3. To center your code use the following:
Your Adsense code here
4. See the screen shot below.
Watch this video on how to Insert Adsense code above the main content
You can also insert Adsense code above the main content into the archives by adding the code to your archives.php.