How do I do this?
You have to bake 5 894 pizza and search the forum ! Or experiment the following…
First you remove the counter. This can be done by using the language file.
Original string is Friends <span class="%s">%s</span>
to replace by eg. Friends
or using this function (add to bp-custom.php)
function bpfr_remove_friends_count( $translated, $original_text, $domain ) {
if ( 'buddypress' !== $domain )
return $translated;
switch ( $original_text ) {
case 'Friends <span class="%s">%s</span>':
return 'Friends';
default:
return $translated;
}
}
add_filter( 'gettext', 'bpfr_remove_friends_count', 10, 3 );
The Friends subnav has only two elements: friendships and request.
Friendships is the default one and can’t be removed. So we have to hide it with css. Add this to your child-theme style.css
#friends-my-friends-personal-li {display:none;}
This is default css, and you have to check it as it can vary depending your theme.
Finally add a new subnav item with counter in replaciement of the one you’ve just hiden (add to bp-custom.php).
function bpfr_custom_profile_sub_nav() {
global $bp;
if( bp_is_active( 'friends' ) )
$count = friends_get_total_friend_count();
$class = ( 0 === $count ) ? 'no-count' : 'count';
//Add subnav item
bp_core_new_subnav_item( array(
'name' => sprintf( __( 'Friendships <span class="%s">%s</span>', 'buddypress' ), esc_attr( $class ), bp_core_number_format( $count ) ),
'slug' => 'friends',
'parent_url' => $bp->loggedin_user->domain,
'parent_slug' => $bp->friends->slug,
'screen_function' => 'friends_screen_my_friends',
'position' => 10
)
);
}
add_action( 'bp_setup_nav', 'bpfr_custom_profile_sub_nav' );
Wow, fantastic response danbp!
It’s 2:30AM here now so I’ll have to try this tomorrow, but thankyou so much for your help anyway – that’s quite a lot of code to come up with!
Now all I have to do is figure out this one: https://buddypress.org/support/topic/post-group-update-directly-in-activity-stream-page/
Hi danbp,
Okay, I found the first function didn’t work, but while I was messing around with it, I found there was a much easier way to do it:
$bp->bp_nav['friends']['name'] = 'Friends';
This is enough to kill the count.
The second function did work – thanks!