Top

Daily Tip: How to Exclude a Group From the Loop in BuddyPress

July 2, 2010

One sure fire way to exclude groups from the loop in BuddyPress is to set them as Private or Hidden in the admin settings. However, if you need the group to be visible in the directory but not in a particular widget, then you’ll have to use a little hack for now.

One example would be if you’re using a group as a shell for a “global forum” and you want to exclude that group from a widget that displays popular groups. BuddyPress documentation for custom group loops doesn’t include a parameter for excluding particular groups, so here’s how you can do it:

<?php while ( bp_groups() ) : bp_the_group();  if(bp_get_group_name() != 'My Group' ) : ?>

Replace ‘My Group’ with the group name that you want to exclude. Also, don’t forget to add an endif; right before the endwhile;

<?php endif; ?>

Many thanks to nahummadrid and r-a-y at the BuddyPress forums for this quick hack.

Tweet This Post


Comments

Got something to say?

Bottom
Article Archive  |  This site is a historical archive of pressography.com, a WordPress plugin and theme blog that published between 2006 and 2012. It is preserved for reference and is not operated by, affiliated with, or endorsed by its original authors. Nothing here is for sale and no form on this site is active. If you are the original owner and would like this domain returned, please get in touch.