Skip to:
Content
Pages
Categories
Search
Top
Bottom

Groups Default Sort By Alpha


  • Andrew Tibbetts
    Participant

    @andrewgtibbetts

    How can I set the main list of Groups be sorted by Alphabetical by default instead of Last Active? I can modify the bp_has_groups query in the template with &type=alphabetical but then the dropdown will no longer affect the sort when changed.

    WP: 4.4.2
    BP: 2.5.2

Viewing 1 replies (of 1 total)

  • Andrew Tibbetts
    Participant

    @andrewgtibbetts

    So, instead of modifying the bp_has_broups query in the template, I figured I needed to do an if / else to check if the user has not set the sort option yet. To do that, in bp-custom.php I hooked in to the bp_ajax_querystring filter:

    add_filter( 'bp_ajax_querystring', 'mediclique_bp_ajax_querystring', 32, 2 );
    function mediclique_bp_ajax_querystring( $query_string, $object ) {
    
    	if ( 'groups' == $object ) {
    	
    		$query_args = wp_parse_args( $query_string, array() );
    	
    		if ( empty( $query_args['type'] ) ) {
    		
    			$query_args['type'] = 'alphabetical';		
    			$query_string = http_build_query( $query_args );
    		}
    	}
    
    	return $query_string;
    }
    
Viewing 1 replies (of 1 total)
  • You must be logged in to reply to this topic.
Skip to toolbar