Skip to content

Create your own follow activity loop

r-a-y edited this page Apr 28, 2013 · 6 revisions

BP allows you to create your own activity loop.

Read this guide for more details: http:https://codex.buddypress.org/developer/developer-docs/loops-reference/the-activity-stream-loop/

Also see how BP creates the loop in the bp-default template: https://buddypress.trac.wordpress.org/browser/tags/1.7/bp-themes/bp-default/activity/activity-loop.php

And the theme compatibility layer: https://buddypress.trac.wordpress.org/browser/tags/1.7/bp-templates/bp-legacy/buddypress/activity/activity-loop.php


However, you'll want to know how you can pass on your following or followers members to the loop.

To do so, pass the user_id parameter into the activity loop using either bp_get_following_ids() or bp_get_follower_ids().

Like this:

// create an activity loop displaying only activity items that user ID 3 is following
if ( bp_has_activities( array(
	// change the user ID below to whatever
	'user_id' => bp_get_following_ids( 'user_id=3' )
) ) ) :

// rest of the loop here

For a full list of parameters you can pass to the activity loop, see: https://buddypress.trac.wordpress.org/browser/tags/1.7/bp-activity/bp-activity-template.php#L339