My income from Google Adsense programme is slowly growing and I have decided to have a closer look and try to improve it further. At the moment I have four websites and I have just noticed that on forum of quite popular personal finance website smartpolak.co.uk there are not many ads. I have decided to add one advertisement just below the breadcrumbs 🙂
To do so I could use one of the available plugins however I believe that installing a large number of different plugins slow the website and I try to keep their number to as low as possible. So in the end I decided to edit the bbpress post file and insert the code that will generate the add directly into the file. The only problem with this solution you need to remember is that when bbpress will be at some point updated, your edited file will be deleted, the ads will stop showing and you will have to do it all over again. As you will see below it is relatively painless procedure so it is not a big problem.
How to add adsense ad to bbpress forum
#1 Grab the Adsense code
First things first, to insert the code into your bbpress forum you first need to have it. Head to Adsense.com and log into your account. Then click on My ads in the left hand side menu and then click on Add new unit. Choose type of the add you want to display (Text and display ads work best for me I also use responsive ads), name your ad and, if you want to access some stats later on, create/set a custom channels. Click on the button Save and get the code. You should see something like that:
Copy the code somewhere handy (I usually use Notepad for this) or leave the tab of your browser open.
#2 Copy content-single-topic.php from bbpress to your computer
Now you need to connect to your website and copy one of the bbpress files. The easiest way is to use FTP client, I use a small but effective program called Total Commander. I hope you know how to connect to the server if not use comments below or ask your hosting company. Once connected to the server via FTP, you need to go to root folder of your website (in my case it is public_html folder). Next, go deeper to: wp-content/plugins/bbpress/templates/default/bbpress . Once you got there copy content-single-topic.php file to your PC.
The file you copied determines the look of a single bbpress post but there are other files you can use as well depending on where you would like the advertisements appear. I think that using content-single-topic.php makes sense. People will see the information about post in search results and they click to read it. Then, the page will be loaded and the add display.
#3 Open and edit php file
So the file is on your PC now. Open it in the editor of your choice. You can edit it even in Notepad if you do not have anything else. Now, if you, like me, want to display your ad just below the breadcrumbs, you need to put he Adsense code just below . It makes sense to use a div with a class to have better control how this ad is displayed via CSS file of your WordPress theme. So the whole code you put below could look like:
Once you added the code to the file do not forget to save it 🙂
#4 Upload the file back to the server
You can now send the file back to the server. As a precaution in the FTP client you may rename the original file that is still in the server to something like content-single-topic.OLD (in case something goes wrong you can quickly rename it back to the original and restore the website). But if you followed my instruction you should be OK.
So send the modified file with Adsense code back to the server. You you haven’t changed the original, your FTP client will ask if you want to overwrite it. Agree and that is all really, the first ads should start appearing after 10-15 minutes 🙂 In my case forum below was a bit high and it was partly hidden below the add. To solve it I have put 25 pixels margins on top and bottom of the div I created. If you remember, that is why I use div with the class, to control the ad. If you have similar problem, do the same. Your wordpress theme should have some functionality to add new css classes.
Adding Adsense to bbpress video tutorial
If you prefer all this information in the video format, have a look at my quick Youtube tutorial:
That is all this time, thank you very much for reading. As always, please feel free to write comments below if you have any questions.