I wrote a couple of days ago about how I customized the bp_has_groups() function to alphabetize my “All Groups” page in BuddyPress. But I have since been using that function to customize all sorts of things.
For example, the Group Authors List plugin by Eric Johnson displays a list of the most recently active 20 groups in its widget drop-down by default. I needed to do two things – display ALL the groups in the dropdown and alphabetize the listing of the groups. This was easy to do. I changed this:
<?php if ( bp_has_groups() ) : while ( bp_groups() ) : bp_the_group(); ?>
<?php if ( bp_has_groups('type=alphabetical&per_page=100') ) : while ( bp_groups() ) : bp_the_group(); ?>
But that’s not all! I also was having an issue with the groups listing’s AJAX, whereby the pagination was not working correctly. Rather than try to figure out how all that is put together (which would have been nice, btw, except time is of the essence), I simply added “per_page=100” to the bp_has_groups() function.
I am starting to realize that this function can be used much in the same way that “query_posts()” is used in normal WordPress theming.