The get_site_option() WordPress PHP function retrieves an option value for the current network based on the name of the option.
Usage
get_site_option( 'option_name', 'default_value', 'use_cache' );
Parameters
- $option (string) (Required): Name of the option to retrieve. Expected to not be SQL-escaped.
- $default_value (mixed) (Optional): Value to return if the option doesn’t exist. Default: false
- $deprecated (bool) (Optional): Whether to use cache. Multisite only. Always set to true. Default: true
More information
See WordPress Developer Resources: get_site_option
Examples
Retrieve site URL
Retrieve the site URL for the current network.
$site_url = get_site_option( 'siteurl' ); echo "Site URL: " . $site_url;
Retrieve non-existent option with default value
Retrieve a non-existent option and provide a default value if the option doesn’t exist.
$non_existent_option = get_site_option( 'i_dont_exist', 'Default Value' ); echo "Non-existent Option: " . $non_existent_option;
Retrieve admin email
Retrieve the admin email for the current network.
$admin_email = get_site_option( 'admin_email' ); echo "Admin Email: " . $admin_email;
Retrieve site language
Retrieve the site language for the current network.
$site_language = get_site_option( 'WPLANG' ); echo "Site Language: " . $site_language;
Retrieve the allowed themes
Retrieve the allowed themes for the current network.
$allowed_themes = get_site_option( 'allowedthemes' ); foreach ( $allowed_themes as $theme => $status ) { echo "Theme: " . $theme . " | Status: " . $status . "<br>"; }