# BuddyPress: Members per Page in the Directory

> Changes how many members the BuddyPress members directory shows per page, and can switch the default order to alphabetical.

- Type: PHP
- Runs: Run everywhere
- Category: [Users](https://wpide.com/library/category/users/)
- Tags: buddypress, directory, members
- Author: WPIDE Team
- Installs: 0
- Updated: 2026-10-28
- Page: https://wpide.com/library/buddypress-members-per-page/

## Code

```php
if ( ! function_exists( 'buddypress' ) ) {
    return;
}

$wpide_bp_members_per_page = 48;
// "alphabetical", "newest", "active" or "" for the default.
$wpide_bp_default_order    = 'alphabetical';

add_filter( 'bp_after_has_members_parse_args', function ( $args ) use ( $wpide_bp_members_per_page, $wpide_bp_default_order ) {
    if ( ! bp_is_members_directory() && ! wp_doing_ajax() ) {
        return $args;
    }

    $args['per_page'] = $wpide_bp_members_per_page;

    // Only change the order when the visitor has not picked one.
    if ( $wpide_bp_default_order && empty( $_REQUEST['type'] ) && empty( $_REQUEST['filter'] ) ) {
        $args['type'] = $wpide_bp_default_order;
    }

    return $args;
} );
```

## Notes

Set $wpide_bp_default_order to "" to keep BuddyPress's own "last active" order.

## How to use it

Install the free WPIDE plugin (https://wordpress.org/plugins/wpide/), find "BuddyPress: Members per Page in the Directory" in its snippet library and add it in one click; or create a new PHP snippet in WPIDE (or any code snippets plugin) and paste the code above. More snippets: https://wpide.com/library/
