Skip to content

Instantly share code, notes, and snippets.

@imath
Created May 26, 2016 09:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save imath/039456f31f48596ec0e41efa98b5946a to your computer and use it in GitHub Desktop.
Save imath/039456f31f48596ec0e41efa98b5946a to your computer and use it in GitHub Desktop.
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