get_site_option() WordPress Function

The get_site_option() function is used to retrieve a site option value from the database. The value is stored as a serialized string, so it will need to be unserialized before it can be used. This function is only available on multisite installations.

get_site_option( string $option, mixed $default = false, bool $deprecated = true ) #

Retrieve an option value for the current network based on name of option.


Description

Top ↑

See also


Top ↑

Parameters

$option

(string)(Required)Name of the option to retrieve. Expected to not be SQL-escaped.

$default

(mixed)(Optional) Value to return if the option doesn't exist.

Default value: false

$deprecated

(bool)(Optional)Whether to use cache. Multisite only. Always set to true.

Default value: true


Top ↑

Return

(mixed) Value set for the option.


Top ↑

More Information

This function is almost identical to get_option(), except that in multisite, it returns the network-wide option. For non-multisite installs, it uses get_option.

It is easy to get confused about the difference between get_option() and get_site_option(), because multisite used different terms before. Now there are different “sites” on a “network”, before there where different “blogs” on a “site”. Many functions and variables were introduced before this change, such as this one. Think of this function as “get_network_option()


Top ↑

Source

File: wp-includes/option.php

function get_site_option( $option, $default = false, $deprecated = true ) {
	return get_network_option( null, $option, $default );
}


Top ↑

Changelog

Changelog
VersionDescription
4.4.0Modified into wrapper for get_network_option()
2.8.0Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by the Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.

Show More