Skip to content

Instantly share code, notes, and snippets.

@imath

imath/bp-custom.php Secret

Created May 26, 2016
Embed
What would you like to do?
Force the Groups loop query to get groups having a specific tag
<?php
function bp_groups_taxo_loop() {
$bp = buddypress();
$reset_term = 0;
$reset_tax_query = array();
if ( ! empty( $bp->groups->tag->term ) ) {
$reset_term = $bp->groups->tag->term;
}
if ( ! empty( $bp->groups->tag->tax_query ) ) {
$reset_tax_query = $bp->groups->tag->tax_query;
}
// Set the term
$bp->groups->tag->term = BP_Groups_Terms::get_term_by( 'slug', 'thetagslug' );
// The Groups loop.
bp_get_template_part( 'groups/groups-loop' );
$bp->groups->tag->term = $reset_term;
$bp->groups->tag->tax_query = $reset_tax_query;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment