ms_sites_list_table_query_args is a WordPress PHP filter that allows you to modify the arguments for the site query in the sites list table.
Usage
add_filter('ms_sites_list_table_query_args', 'your_custom_function', 10, 1); function your_custom_function($args) { // your custom code here return $args; }
Parameters
$args
(array): An array ofget_sites()
arguments.
More information
See WordPress Developer Resources: https://developer.wordpress.org/reference/hooks/ms_sites_list_table_query_args/
Examples
Change the number of sites displayed
Limit the number of sites displayed to 50.
function limit_sites_to_50($args) { $args['number'] = 50; return $args; } add_filter('ms_sites_list_table_query_args', 'limit_sites_to_50', 10, 1);
This code sets the maximum number of sites to retrieve to 50.
Filter sites by specific network ID
- Display sites belonging to network ID 2.
function filter_sites_by_network($args) { $args['network_id'] = 2; return $args; } add_filter('ms_sites_list_table_query_args', 'filter_sites_by_network', 10, 1);
This code filters the sites list table to show only sites belonging to network ID 2.
Exclude sites with specific IDs
Exclude sites with IDs 3 and 4 from the list.
function exclude_sites_by_id($args) { $args['site__not_in'] = array(3, 4); return $args; } add_filter('ms_sites_list_table_query_args', 'exclude_sites_by_id', 10, 1);
This code excludes sites with IDs 3 and 4 from the sites list table.
Order sites by last_updated date
Order the sites by their last updated date, in descending order.
function order_sites_by_last_updated($args) { $args['orderby'] = 'last_updated'; $args['order'] = 'DESC'; return $args; } add_filter('ms_sites_list_table_query_args', 'order_sites_by_last_updated', 10, 1);
This code orders the sites list table by the last updated date in descending order.
Filter sites by domain
Show only sites with the domain “example.com”.
function filter_sites_by_domain($args) { $args['domain'] = 'example.com'; return $args; } add_filter('ms_sites_list_table_query_args', 'filter_sites_by_domain', 10, 1);
This code filters the sites list table to show only sites with the domain “example.com”.