Title: WP_Network::__get
Published: August 16, 2016
Last modified: April 28, 2025

---

# WP_Network::__get( string $key ): mixed

## In this article

 * [Description](https://developer.wordpress.org/reference/classes/wp_network/__get/?output_format=md#description)
 * [Parameters](https://developer.wordpress.org/reference/classes/wp_network/__get/?output_format=md#parameters)
 * [Return](https://developer.wordpress.org/reference/classes/wp_network/__get/?output_format=md#return)
 * [Source](https://developer.wordpress.org/reference/classes/wp_network/__get/?output_format=md#source)
 * [Related](https://developer.wordpress.org/reference/classes/wp_network/__get/?output_format=md#related)
 * [Changelog](https://developer.wordpress.org/reference/classes/wp_network/__get/?output_format=md#changelog)

[ Back to top](https://developer.wordpress.org/reference/classes/wp_network/__get/?output_format=md#wp--skip-link--target)

Getter.

## 󠀁[Description](https://developer.wordpress.org/reference/classes/wp_network/__get/?output_format=md#description)󠁿

Allows current multisite naming conventions when getting properties.

## 󠀁[Parameters](https://developer.wordpress.org/reference/classes/wp_network/__get/?output_format=md#parameters)󠁿

 `$key`stringrequired

Property to get.

## 󠀁[Return](https://developer.wordpress.org/reference/classes/wp_network/__get/?output_format=md#return)󠁿

 mixed Value of the property. Null if not available.

## 󠀁[Source](https://developer.wordpress.org/reference/classes/wp_network/__get/?output_format=md#source)󠁿

    ```php
    public function __get( $key ) {
    	switch ( $key ) {
    		case 'id':
    			return (int) $this->id;
    		case 'blog_id':
    			return (string) $this->get_main_site_id();
    		case 'site_id':
    			return $this->get_main_site_id();
    	}

    	return null;
    }
    ```

[View all references](https://developer.wordpress.org/reference/files/wp-includes/class-wp-network.php/)
[View on Trac](https://core.trac.wordpress.org/browser/tags/6.9.4/src/wp-includes/class-wp-network.php#L151)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/6.9.4/src/wp-includes/class-wp-network.php#L151-L162)

## 󠀁[Related](https://developer.wordpress.org/reference/classes/wp_network/__get/?output_format=md#related)󠁿

| Uses | Description | 
| [WP_Network::get_main_site_id()](https://developer.wordpress.org/reference/classes/wp_network/get_main_site_id/)`wp-includes/class-wp-network.php` |

Returns the main site ID for the network.

  |

## 󠀁[Changelog](https://developer.wordpress.org/reference/classes/wp_network/__get/?output_format=md#changelog)󠁿

| Version | Description | 
| [4.6.0](https://developer.wordpress.org/reference/since/4.6.0/) | Introduced. |

## User Contributed Notes

You must [log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Fclasses%2Fwp_network%2F__get%2F)
before being able to contribute a note or feedback.