Re-ordering a custom groups loop
-
Hello,
I’ve created a new page template that shows groups with a specific meta value (I call this the group category).
This is how I call the groups loop in the page template :
<!-- Category specific groups loop --> <?php get_template_part( 'category-specific-groups' ); ?>
And this is how I customize the groups loop:
// Get group tag of the page $group_tag = get_post_meta(get_the_ID(), 'group-tag', true); // Custom Group Query with specified Group Category (Meta query) $query_args = array ( 'type' => 'popular', 'per_page' => 2, ); $query_args['meta_query'] = array( array( 'key' => 'group-category', 'value' => $group_tag, 'compare' => '=' ) ); if ( bp_has_groups( $query_args ) ) : while ( bp_groups() ) : bp_the_group(); // template endwhile; endif;
This all works nicely.
Now I’ve added the Order By filters to the page template and I’d like those options to update the groups query.
I assume I need to pass the value from the selection to here:
$query_args = array ( 'type' => '<Order By value>', 'per_page' => 2, );
This is how the selection form looks on my page template:
<select id="groups-order-by"> <option value="active">Last Active</option> <option value="popular">Most Members</option> <option value="newest">Newly Created</option> <option value="alphabetical">Alphabetical</option> <?php do_action( 'bp_groups_directory_order_options' ); ?> </select>
Any suggestions how to best go about this?
Thanks!
Herman
Viewing 4 replies - 1 through 4 (of 4 total)
Viewing 4 replies - 1 through 4 (of 4 total)
- The topic ‘Re-ordering a custom groups loop’ is closed to new replies.