bp_get_activity_root_slug() | Get Activity directory | Buddypress function reference

In older versions of Buddypress which are bellow 1.5.x, Members, Activity, Groups,… etc buddypress pages were made automatically without creating any pages ( wp-admin->pages ), So that URL structure were same for all buddypress site,

for Activity directory, it was example.com/activity

for Members directory, example.com/members … etc

But since Buddypress 1.5.x versions, it provides us flexibility to select BP pages ( Members, Activity, Groups ) name, slug, url as our own wish, so I can change activity directories name, url as I want, as example, if I change ‘Activity’ directory’s name to ‘Streams’, then my site’s activity url will be example.com/streams

So, you have to know your activity page’s slug for easier access, as like, lets say you know a particular activity id (as example, 17 ) , you want to see that particular activity only, if you know activity directory’s slug, you can simply type example.con/ACTIVITY_SLUG/p/17 (ACTIVITY_SLUG = your activity slug, for me, it is streams),

Some plugins which are released before buddypress 1.5.x used directly default activity page slug (example.com/activity), so if you want to change activity slug, this plugins may produce ‘404 Not Found’ error, in that case you need to get activity slug name dynamically.

bp_get_activity_slug() this function returns you the activity directory’s slug,

as example, I want to show my activity slug name at my sidebar, So, How can I get buddypress activity slug name? simple I’ll type,

<?php echo bp_get_activity_root_slug() ?>

or if I dont want to use php echo function, I can use just <?php bp_activity_root_slug() ?> (this function echo internally)

[codesyntax lang=”php”]

function bp_get_activity_root_slug() {
global $bp;
return apply_filters( ‘bp_get_activity_root_slug’, $bp->activity->root_slug );


bp_get_activity_root_slug() information:

Defined in: buddypress/bp-activity/bp-activity-template.php Line 46

Return: Buddypress activity directory slug

Parameter takes: none