Building websites with WordPress is easy until you have to start editing the code behind the website. However this is necessary in order to add AdSense code into your posts as it lines it up nicely. You can use a plugin for this but I find the less plugins the better.
Adding this code into your template means it will automatically be added to every post you create in your WordPress website. If you add AdSense into your templates you will not have to touch it again and the less you play with the code of your website, the better. I will show you how to add AdSense to your posts so it will line up with the text, embed itself, and look like it is meant to be there.
- Sign into your WordPress Admin area.
- Click on the Appearance menu.
- Then click on Editor. See the screenshot below.
- You will be taken to the WordPress code editor. Click on Single.php in the right column. See the screenshot below.
- When the single.php code shows up you can copy all of it and paste it to a notepad, just in case you stuff something up. This is very important. Do not move any text or even add a space where it is not meant to be. Just copy it and make a quick backup of the code. You can press in the code box and then press CTRL + A to select all. Then right click on the selection to choose copy.
- Ok after you have backed up this code we can now add something to it. Look for where the content begins. The code will look something like this or something similar. See the screenshot below.
- We are going to add our code before this.
- Here’s the code
<div style="display:block;float:left;padding:5px;"> <add your adsense code here> </div>
- Sometimes you might need to put <p> and </p> tags to make a paragraph around all of this. It really depends what WordPress theme you are using. As you can see in the screenshot above, I have used the <p> tag. On some websites I do not have to.
When you are finished adding your AdSense code in WordPress, press the update button below the code window.
You can also add Adsense to a thesis theme or add Adsense to WordPress using a plugin.
If you have backed up your code you can keep adjusting this until you get it right. Then if you can’t work it out, just paste the original code back in and press on update to save. When playing with the WordPress code editor make sure you are not cutting code when you are meant to be copying it…Anyway you shouldn’t have to worry if you make a backup.