How to manually add Adsense to bbPress Forums

Updated November 18th, 2018
Updated November 18th, 2018
Share this post:

In this tutorial, you will learn how to add Adsense to bbPress forums by editing template files. There is a plugin called Advanced Ads that has a premium version that allows you to add adsense to bbPress. It’s a lot easier to do that way, but it is not free. What you’ll learn to day is free.

You can either watch the detailed video tutorial below or scroll below that to read the image/text version of the tutorial.

It goes without saying, but I’m saying it anyway, that you need to have bbPress forums created already for this to work. If you need help with that here’s a step-by-step YouTube tutorial for setting a forum.

Advertisement

Finding The bbPress Template Files

The first step is to access the cPanel file manager

Advertisement

Next, you’ll need to find your bbPress templates as shown on the animated GIF below.

The file named content-archive-forum.php is responsible for the main forum on your site. Click on it to highlight it and then click on the Code Editor button.

In the Code Editor you will see all the PHP that is responsible for creating the main forum page. Inside this file is where we’ll put our first set of adsense ads.

Advertisement

But, before we do that, I must warn you NOT to disrupt the code and break the PHP functions. If you do you’ll see a “white screen of death”. If that happens, just undo what you did and that will fix it.

Let’s take a look at the code.

Even if you don’t know PHP you can get a sense of what is going on by reading the function names. Then you can strategically place your adsense code.

Or, if you prefer the quick and dirty method, just type different, short phrases through the code. Then save changes and reload the main forum page.

You’ll see your phrases through the page. Now you can add real adsense code exactly where you want on the first try.

Make sure you delete all the phrases you put in there when you’re done.

Advertisement

In the example illustrated with the screenshots, I’m using the phrase “adsense code”.

I put the phrase before the first opening div on the main forum template page then saved my changes.

You can see the phrase appears above the forums list when the live page is refreshed.

Now I want to see where the area below the forum list is.

Type in “adsense code” just above the last closing div in the file and save changes.

As you can see below, on the live page, the phrase appears below the forum list.

Advertisement

Again, bear in mind that this is just a simplified example. For real ads to appear, you will have to paste in the actual Adsense code instead of just a phrase. This is just to show you where the ads will be placed.

The process is the same for each page you want to add adsense to. You just need to find the right template and paste the adsense code inside the code editor. In the video at the top of the page I walk you through a bunch more template files to show you where the code would go.

A big problem with this method is that an update might overwrite your changes and there’s no such thing as a child plugin which can protect your changes.

This process is pretty straightforward, but if you want advanced features and you’re not familiar with coding, it would be safer to pay $29 bucks for the premium Advanced Ads plugin.

For customizing your WordPress site further, make sure you subscribe to my WordPress Tutorials – WPLearningLab channel and click on the bell notification not to miss any of the useful WordPress tutorials.

Share this post:

Responses

Your email address will not be published. Required fields are marked *

WPLearningLab