# Sort the Network Sites List by Recent Activity

> Opens Network Admin > Sites sorted by "last updated" with the most recently active sites first, instead of by ID, so the sites people are working on are always at the top.

- Type: PHP
- Runs: Admin only
- Category: [Multisite](https://wpide.com/library/category/multisite/)
- Tags: network-admin, sites, sorting
- Author: WPIDE Team
- Installs: 0
- Updated: 2026-10-28
- Page: https://wpide.com/library/ms-sites-list-newest-activity-first/

## Code

```php
if ( ! is_multisite() ) {
    return;
}

add_filter( 'ms_sites_list_table_query_args', function ( $args ) {
    if ( empty( $_GET['orderby'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification
        $args['orderby'] = 'last_updated';
        $args['order']   = 'DESC';
    }

    return $args;
} );
```

## Notes

Clicking a column header still sorts by that column.

## How to use it

Install the free WPIDE plugin (https://wordpress.org/plugins/wpide/), find "Sort the Network Sites List by Recent Activity" 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/
