adv/content in activity steam

Home Forums Cera – Intranet & Community Theme Feature Requests adv/content in activity steam

This topic contains 5 replies, has 3 voices, and was last updated by  Olivier 4 weeks, 1 day ago.

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #14735

    Andrea
    Participant
    • 108 Posts
    @youfriend

    For add extra content or ads in the activity stream i have found this amazing post, but
    Unfortunately not work with Adsense. any ideas?

    Inject content into BuddyPress Activity stream after a certain number of activities

    code:

    /**
     * Inject content into BuddyPress Activity stream after 'n' activities.
     */
    function buddydev_inject_content_after_n_activities() {
        static $current_activity_index = 1;
     
        // change $n to the correct number of activities.
        $n = 5; // After how many activities you want to inject content.
     
        if ( $current_activity_index % $n === 0 ) {
            ?>
            <li class='activity-item activity-ad-item activity-custom-entry'>
                Your code snippet ...
            </li>
            <?php
            // show the activity injected content.
        }
        // increment the current index.
        $current_activity_index ++;
     
    }
     
    add_action( 'bp_after_activity_entry', 'buddydev_inject_content_after_n_activities' );
    #14798

    Manathan
    Keymaster
    • 415 Posts
    @themodactyl
    Themosaurus Support

    Hi @youfriend,

    Thanks for getting in touch! We’ve received your request and we’ll get you an answer shortly. 🙂

    We really thank you for your patience!

    Kind regards,

    #14927

    Olivier
    Moderator
    • 1758 Posts
    @themosaurusrex
    Themosaurus Support

    @youfriend,

    AdSense seams to be very JavaScript based and some other code is probably messing with your snippet. I have reached this conclusion after reading this:
    https://www.wpbeginner.com/beginners-guide/how-to-add-google-adsense-to-your-wordpress-site/

    Do you have AdSense already activated on your website? And does it work in your sidebar widget areas?

    Thank you.

    #14931

    Andrea
    Participant
    • 108 Posts
    @youfriend

    yep work it everywhere

    #14939

    Andrea
    Participant
    • 108 Posts
    @youfriend

    Im try this snippet, work but just for 1 adv after 5 activities (better of nothing)

    function custom_markup_before_every_fifth_activity() {
    global $activities_template;
    
    $item_5 = $activities_template->activities[4];
    
    if ( $item_5->id === $activities_template->activity->id ) {
    
    echo 'adv here';
    }
    };
    add_action( 'bp_before_activity_entry', 'custom_markup_before_every_fifth_activity' );
    #15199

    Olivier
    Moderator
    • 1758 Posts
    @themosaurusrex
    Themosaurus Support

    @youfriend Thank you for sharing your findings with the rest of us!
    I went through the following posts:

    how to make this code work properly to put ads in buddypress activity


    https://wordpress.org/support/topic/buddypress-ad-placements/

    Adsense on activity stream?

    I also stumbled upon this plugin but it has very few active installations and I haven’t had the chance to test it with Cera:

    Buddypress Ads

    My conclusion is that there is not much we can do with our theme because I haven’t found any plugin or any simpler ways to achieve this. Any attempt to insert AdSense adds into the BuddyPress activity stream require custom coding…

    Maybe this topic will spark others interest and we could decide in the future to implement this feature in a plugin ourselves if other community members upvote your request. So, I think that we should leave this open for further comments.

    Please note that I took the liberty to move this topic to our Feature Requests forum. 🙂

Viewing 6 posts - 1 through 6 (of 6 total)

You must be logged in to reply to this topic.