Description
Retrieve a network option value based on option name.
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.
Usage
<?php get_site_option( $option, $default , $use_cache ) ?>
Parameters
- $option
- (string) (required) The name of the option to retrieve. Expected to not be SQL-escaped .
- Default: None
- $default
- (mixed) (optional) A value to return if the option doesn't exist.
- Default: false
- $use_cache
- (boolean) (optional) Whether to use the cache. This has no effect on non-multisite installs.
- Default: true
Return Values
- (mixed)
- Current value for the specified option. If the specified option does not exist, returns boolean FALSE.
Examples
Default Usage
echo get_site_option( 'siteurl' );
Passing a Default Value
$value = get_site_option( 'i_dont_exist' );
// $value == false
$value = get_site_option( 'i_dont_exist', 'blah' );
// $value == 'blah'
Notes
- 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()".
Change Log
Source File
get_site_option()
is located in wp-includes/option.php
.
Related