get_site_option()WP 2.8.0

Gets the specified option of the main site of the current network.

Such options are stored in the meta-fields of the network sites - table wp_sitemeta.

The function is very similar to the basic get_option(), only it retrieves data from the wp_sitemeta table, not from wp_options.

This is a wrapper for the get_network_option() function, so read the detailed description at the link.

Control is passed to get_option() when multisite mode is not used.

No Hooks.

Returns

Mixed. The value of the option.

Usage

get_site_option( $option, $default );
$option(string) (required)
The name of the option to retrieve. Expects an unprepared string for SQL query.
$default(mixed)
The value to return if the option does not exist.
Default: false
$deprecated(boolean)
Deprecated since version 4.4.0. Whether to use cache. Only for multisites.
Default: true

Examples

0

#1 Get the network administrator's email

$admin_email = get_site_option( 'admin_email' );
0

#2 Get siteurl of the main network site

echo get_site_option( 'siteurl' );
0

#3 Set a Default Value

$value = get_site_option( 'i_dont_exist' );

// $value == false

$value = get_site_option( 'i_dont_exist', 'blah' );

// $value == 'blah'

List of some network site options:

Option Name Value
site_name Multisite
admin_email [email protected]
admin_user_id 1
registration user
upload_filetypes jpg jpeg png gif mov avi mpg 3gp 3g2 midi mid pdf doc ppt odt pptx docx pps ppsx xls xlsx key mp3 ogg wma m4a wav mp4 m4v webm ogv wmv flv
blog_upload_space 100
fileupload_maxk 1500
site_admins a:1:{i:0;s:4:"nick";}
allowedthemes a:1:{s:19:"twentysixteen-child";b:1;}
wpmu_upgrade_site 37965
welcome_email Hello, USERNAME! Your new site in the "SITE_NAME" network has been successfully created at: ....
first_post Welcome to the site %s. This is your first post. Edit or delete it, then write!
siteurl http://multiexample.com/wp/
add_new_users 1
upload_space_check_disabled 1
subdomain_install 1
global_terms_enabled 0
ms_files_rewriting 0
initial_db_version 36686
active_sitewide_plugins a:1:{s:33:"user-switching/user-switching.php";i:1473022930;}
WPLANG ru_RU
user_count 4
blog_count 3
can_compress_scripts 1
recently_activated a:1:{s:28:"democracy-poll/democracy.php";i:1473020642;}
registrationnotification yes
welcome_user_email Hello, USERNAME! Your account has been set up. ....
menu_items a:0:{}
first_page ''
first_comment ''
first_comment_url ''
first_comment_author ''
limited_email_domains ''
banned_email_domains ''
first_comment_email ''

Notes

Changelog

Since 2.8.0 Introduced.
Since 4.4.0 The $use_cache parameter was deprecated.
Since 4.4.0 Modified into wrapper for get_network_option()

get_site_option() code WP 7.0

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