The get_network WordPress PHP filter is used to modify the network data after it has been retrieved.
Usage
add_filter('get_network', 'your_custom_function', 10, 1); function your_custom_function($_network) { // your custom code here return $_network; }
Parameters
- $_network (WP_Network): The network data object that you want to modify.
More information
See WordPress Developer Resources: get_network
Examples
Change the network’s path
Modify the network’s path to include a custom subdirectory:
add_filter('get_network', 'change_network_path', 10, 1); function change_network_path($_network) { $_network->path = '/custom_subdirectory' . $_network->path; return $_network; }
Add custom data to the network object
Add a custom property to the network object:
add_filter('get_network', 'add_custom_data', 10, 1); function add_custom_data($_network) { $_network->custom_data = 'Some custom information'; return $_network; }
Modify the network’s domain
Change the network’s domain to a custom one:
add_filter('get_network', 'change_network_domain', 10, 1); function change_network_domain($_network) { $_network->domain = 'customdomain.com'; return $_network; }
Add a prefix to the network’s site name
Add a prefix to the network’s site name:
add_filter('get_network', 'add_prefix_to_site_name', 10, 1); function add_prefix_to_site_name($_network) { $_network->blog_name = 'My Network - ' . $_network->blog_name; return $_network; }
Change the network’s language
Modify the network’s language to a different one:
add_filter('get_network', 'change_network_language', 10, 1); function change_network_language($_network) { $_network->language = 'en_US'; return $_network; }