Skip to:
Content
Pages
Categories
Search
Top
Bottom

Add ad code into activity stream

  • Avatar of bhekzin
    bhekzin
    Participant

    @bhekzin

    Hello everyone. This is my first time on the forum. I’m more of a server config and admin guy but i also develop sites with WordPress as i find it extremely easy. My current project is a community site. Installed Buddypress and some plugins that will give users a splendid experience. Configured an ad server (revive ad server). Created zones, uploaded banners and all ads are rotating on their respective zones on the site. Got stuck on rotating ads on SimplePress forums but got this, and that was quickly fixed. Only one problem. I cant find a way of inserting ad code on the Buddypress activity stream. I spent hours searching but all the stuff i got does not work or worked on previous versions of buddypress. Please help

Viewing 7 replies - 1 through 7 (of 7 total)
  • Avatar of henrywright
    henrywright
    Moderator

    @henrywright

    There’s a function you can use to do that called bp_activity_add(). See here for the usage:

    http://codex.buddypress.org/developer/function-examples/bp_activity_add/

    Avatar of bhekzin
    bhekzin
    Participant

    @bhekzin

    I will give it a shot when i get to my lab. So how am i gonna customize this code to make my adds appear lets say after a couple of posts and in between a certain number of posts on the activity stream?

    Avatar of henrywright
    henrywright
    Moderator

    @henrywright

    @bhekzin you’ll need to decide if you’re going to add an ad after X number of items have been added to the stream or if you’re going to add an ad every X number of seconds (or minutes, or hours). If you choose the interval approach, check out wp_schedule_event

    https://codex.wordpress.org/Function_Reference/wp_schedule_event

    Avatar of bhekzin
    bhekzin
    Participant

    @bhekzin

    My approach is to add an ad after every 8 posts on the stream. So what will the code look like to achieve this? I’m sorry but i’m no coder. I’m used to configuring plug ins and stuff, but there is no plugin for what i wanna achieve.

    Avatar of henrywright
    henrywright
    Moderator

    @henrywright

    @bhekzin actually, instead of adding the ad as an activity item, you could just modify the activity loop to insert the ad dynamically on every 8th item. This is how you’d do that using a for loop:

    for ( $i = 1; $i < 1000; $i++ ) {
        if ( $i % 8 == 0 ) {
           // this is the 8th item so insert your ad code
        }  
    }
    Avatar of bhekzin
    bhekzin
    Participant

    @bhekzin

    @Henry i’m not having any luck. The ads are rotating but at the bottom of the stream with code around them. [IMG]http://i58.tinypic.com/2rwu6aq.jpg[/IMG]

    Avatar of sg107
    sg107
    Participant

    @sg107

    Were you able to solve your issue? I think there is a plugin for this. Try a Google search for adsense in BuddyPress activity stream etc.

Viewing 7 replies - 1 through 7 (of 7 total)

You must be logged in to reply to this topic.