Skip to:
Content
Pages
Categories
Search
Top
Bottom

Re: How to query for groups


Boone Gorges
Keymaster

@boonebgorges

@ajaxmac – If you want to get group activity updates, you’ll want to query for *activities* rather than groups. Check out bp_has_activities() https://codex.buddypress.org/developer-docs/custom-buddypress-loops/the-activity-stream-loop/. For example, you can get the last five activity updates from a group with a loop containing the following query:
if ( bp_has_activities( 'max=5&object=groups&primary_id=' . $group_id ) ) (obviously you’ll have to get that $group_id from somewhere).

Then use the rest of the activity loop to display the content. Check out buddypress/bp-themes/bp-default/activity/entry.php to see how bp-default displays a single activity item within the loop, and activity-loop.php to see an (albeit complicated) example of how bp-default initializes the loop with a query.

Skip to toolbar