Enable ads on Buddypress Website

Hello everyone ! Today I am available with an important tutorial on how to enable ads on the Buddypress website. There are plugins available which can do this work for you. But, if you like to control things and do not want to install plugins for a small work. You are on right place. But before proceeding to the tutorial, You should know the following things

1. How to add bp-custom.php file in buddypress
2. You should have basic knowledge of coding language like php, html and css

Enable ads on Buddypress Website   

Let us begin. In order to add ads in between the Buddypress activities. you should add below code in your bp-custom.php file 

Let us try to understand what our code is doing.
We are defining a function called my_activity_ads and then we will hook that function with bp_before_activity_entry. What it does it will add the Adsense code before an activity entry according to the conditions defined in if statement. In the if condition we are checking if the activity is the 5th, 10th or 15th , We will add the adsense code before activity else not.
If you would like to add adsense  code in the 4th, 8th and 12th activity, you will have to replace the numbers defined in the item variable like $activities_template -> activities[4]
That is it. Now, save the bp-custom.php file and check. Your adsense code will be injected before defined number of activities.

Thanks for reading Enable ads on Buddypress Website . Kindly share and subscribe out website for more tutorials.


Popular posts from this blog

Wordpress on Bluemix - Create a wordpress website

Buddypress Demo Website - Learn Buddypress

IBM Bluemix Pricing For Wordpress Cloud Hosting