Last active
July 22, 2018 15:48
-
-
Save sadrul/38caf0caa65db4a0b3a8 to your computer and use it in GitHub Desktop.
groups query for loop using group meta
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function get_group_ids_by_type($type){ | |
$group_ids = array(); | |
$meta_query = array( | |
array( | |
'key' => 'group_type', | |
'value' => $type, | |
'compare' => '=' | |
) | |
); | |
$groups_args = array( | |
'object' => 'groups', | |
'meta_query' => $meta_query, | |
'per_page' => 0, | |
); | |
if ( bp_has_groups( $groups_args ) ) : | |
while ( bp_groups() ) : bp_the_group(); | |
$group_ids[] = bp_get_group_id(); | |
endwhile; | |
endif; | |
return $group_ids; | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment