How to add Ads to Buddypress Activity Stream?
Don’t know if this is the best way to go about doing it but it works for me.
If you want to ad advertisements – adsense or any other – try this. By modifying the activity-loop.php. You just need to house your ad code where you want and replace the filepath accordingly.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95
<?php /* Querystring is set via AJAX in _inc/ajax.php - bp_dtheme_activity_loop() */ ?>
<?php do_action( 'bp_before_activity_loop' ) ?>
<?php $counter = 0; ?>
<?php if ( bp_has_activities( bp_ajax_querystring( 'activity' )) ) : ?>
<?php /* Show pagination if JS is not enabled, since the "Load More" link will do nothing */ ?>
<noscript>
<div>
<div><?php bp_activity_pagination_count() ?></div>
<div><?php bp_activity_pagination_links() ?></div>
</div>
</noscript>
<?php if ( empty( $_POST['page'] ) ) : ?>
<ul id="activity-stream">
<?php endif; ?>
<?php while ( bp_activities() ) : bp_the_activity(); ?>
<?php $counter++; ?>
<?php include( locate_template( array( 'activity/entry.php' ), false ) ) ?>
<?php if ( BP_ACTIVITY_SLUG == bp_current_component() && bp_is_directory() ) : ?>
<?php if ( $counter == 5 ) { include( TEMPLATEPATH . '/ads/ad_728x90.php' ); } ?>
<?php if ( $counter == 10 ) { include( TEMPLATEPATH . '/ads/ad_728x90.php' ); } ?>
<?php if ( $counter == 15 ) { include( TEMPLATEPATH . '/ads/ad_728x90.php' ); } ?>
<?php endif;?>
<?php endwhile; ?>
<?php if ( bp_get_activity_count() == bp_get_activity_per_page() ) : ?>
<li>
<a href="#more"><?php _e( 'Load More', 'buddypress' ) ?></a> <span></span>
</li>
<?php endif; ?>
<?php if ( empty( $_POST['page'] ) ) : ?>
</ul>
<?php endif; ?>
<?php else : ?>
<div id="message">
<p><?php _e( 'Sorry, there was no activity found. Please try a different filter.', 'buddypress' ) ?></p>
</div>
<?php endif; ?>
<?php do_action( 'bp_after_activity_loop' ) ?>
<form action="" name="activity-loop-form" id="activity-loop-form" method="post">
<?php wp_nonce_field( 'activity_filter', '_wpnonce_activity_filter' ) ?>
</form>

No comments yet.