Retrieves the current network ID.
Return
int The ID of the current network.Source
function get_current_network_id() {
if ( ! is_multisite() ) {
return 1;
}
$current_network = get_network();
if ( ! isset( $current_network->id ) ) {
return get_main_network_id();
}
return absint( $current_network->id );
}
Related
Uses | Description |
---|---|
get_network()wp-includes/ms-network.php | Retrieves network data given a network ID or network object. |
get_main_network_id()wp-includes/functions.php | Gets the main network ID. |
is_multisite()wp-includes/load.php | Determines whether Multisite is enabled. |
absint()wp-includes/functions.php | Converts a value to non-negative integer. |
Used by | Description |
---|---|
wp_prime_network_option_caches()wp-includes/option.php | Primes specific network options into the cache with a single database query. |
wp_count_sites()wp-includes/ms-blogs.php | Counts number of sites grouped by site status. |
wp_insert_site()wp-includes/ms-site.php | Inserts a new site into the database. |
wp_load_press_this()wp-admin/press-this.php | |
update_network_option()wp-includes/option.php | Updates the value of a network option that was already added. |
add_network_option()wp-includes/option.php | Adds a new network option. |
delete_network_option()wp-includes/option.php | Removes a network option by name. |
get_network_option()wp-includes/option.php | Retrieves a network’s option value based on the option name. |
validate_another_blog_signup()wp-signup.php | Validates a new site sign-up for an existing user. |
can_edit_network()wp-admin/includes/ms.php | Determines whether or not this network from this page can be edited. |
WP_MS_Sites_List_Table::prepare_items()wp-admin/includes/class-wp-ms-sites-list-table.php | Prepares the list of sites for display. |
is_main_network()wp-includes/functions.php | Determines whether a network is the main network of the Multisite installation. |
wp_get_sites()wp-includes/ms-deprecated.php | Return an array of sites for a network or networks. |
wp_update_network_site_counts()wp-includes/ms-functions.php | Updates the network-wide site count. |
wp_is_large_network()wp-includes/ms-functions.php | Determines whether or not we have a large network. |
wpmu_activate_signup()wp-includes/ms-functions.php | Activates a signup. |
wpmu_signup_blog_notification()wp-includes/ms-functions.php | Sends a confirmation request email to a user when they sign up for a new site. The new site will not become active until the confirmation link is clicked. |
get_admin_users_for_domain()wp-includes/ms-deprecated.php | Get the admin for a domain/path combination. |
get_active_blog_for_user()wp-includes/ms-functions.php | Gets one of a user’s active blogs. |
get_blog_list()wp-includes/ms-deprecated.php | Deprecated functionality to retrieve a list of all sites. |
get_last_updated()wp-includes/ms-blogs.php | Gets a list of most recently updated blogs. |
wp_xmlrpc_server::wp_getUsersBlogs()wp-includes/class-wp-xmlrpc-server.php | Retrieves the blogs of the user. |
Changelog
Version | Description |
---|---|
4.6.0 | Introduced. |
Warning: This function returns the site_id and not the expected blog_id in multisite context.
I was creating a plugin and used get_current_network_id() to get the current network site. It seemed to fail, because it kept returning 1. The solution was to use get_current_blog_id() .