Hey there, I know this is an old post but the code actually works in BP 1.8. The only minor issue is that the count displays to the far right of the actual favorite link. Any ideas on how to get this next to Favorites like this: Favorite(10) instead of: Favorite delete (10) would be wayy appreciated!
So I answered my own question by just experimenting. I figure I go ahead and let everyone who is interested in this know how I got everything working. I used the following code and placed it in my bp-custom.php
function my_favorite_count() {
$my_fav_count = bp_activity_get_meta( bp_get_activity_id(), 'favorite_count' );
if ($my_fav_count >= 1) : {
if (is_user_logged_in()) : { echo '<span class="fav-count">('.$my_fav_count.')</span>';
}
endif;
}
endif;
}
add_action( 'bp_activity_entry_meta', 'my_favorite_count' );
I added a span class in this code as you can see, and that is how I managed to display the count directly next to favorites button (or link).
I added this to my css:
.fav-count {
margin-left: -15px !important;
}
You may have to play with it to get the margin just right, hope this helps someone.
@ousep, your code still works after all these years.. it shows the count after the favorite button, perhaps not the most elegant solution (in the button, like the comments count, would be ideal) but it works! thank you!
Hi, @tse11, @deepbevel, @ousep
did anyone know a better solution for this in BP 2.0.
The above code is still working but it is not ajax. you have to reload the page to see the count.
Regards