Last active
February 13, 2022 23:12
-
-
Save KaineLabs/8d23610479224cb95c9bda73d16c3667 to your computer and use it in GitHub Desktop.
Insert Ads Between Activity Posts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Set Ads Counter. | |
function yzc_set_global_ads_counter() { | |
global $yzc_ads_count; | |
$yzc_ads_count = 1; | |
} | |
add_action( 'bp_before_activity_loop', 'yzc_set_global_ads_counter' ); | |
// Insert Ads Between each 2 posts. | |
function yzc_add_ads_between_activity_posts() { | |
global $yzc_ads_count; | |
if ( $yzc_ads_count == 1 ) { | |
$yzc_ads_count++; | |
return; | |
} | |
if ( $yzc_ads_count%2 == 1 ) { | |
?> | |
<li class="ad"> | |
<div class="activity-content"> | |
<!-- Ad code here --> | |
</div> | |
</li> | |
<?php | |
} | |
$yzc_ads_count++; | |
} | |
add_action( 'bp_before_activity_entry', 'yzc_add_ads_between_activity_posts' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment