Skip to:
Content
Pages
Categories
Search
Top
Bottom

Reply To: [Resolved] Showing posts by groups

@kypto

Participant

ok, i got it 🙂 i got the right answer sooner, but while i was testing it i chose wrong group so i thought it was wrong. so the right code will be something like this:

$authors = BP_Groups_Member::get_group_member_ids (ID_OF_GROUP_YOU_WANT);
////////// get the ids of members of the group you chose /////////

unset ($authors[0]);
$authorsid = implode(',', $authors);
////////// get rid of the first element in the array "authors" and then make string "authorsid" from that array. /////////

$the_query = new WP_Query( 'author='.$authorsid);
////////// make the query based on authors with the id string parameter /////////

///////// then you make simple post loop, for example: /////////
if ( $the_query->have_posts() ) {
echo '<ul class="news-posts">';
while ( $the_query->have_posts() ) {
$the_query->the_post();
echo '<li>' . get_the_title() . '</li>';
}
echo '</ul>';
} else {}
/* Restore original Post Data */
wp_reset_postdata();
Skip to toolbar