get_site_option() vs get_option()


Note that the function get_site_option() works a bit differently from get_option() on its own. On WordPress Multisite (ie, with Network Mode enabled), there are two different kinds of options:

site-specific options, which are stored in the individual options tables for each blog (wp_options, wp_5_options, etc). These options are accessed with get_option(), update_option(), etc. Note that this assumes that the current blog - the one set in $wpdb→blog_id - is the blog from which you want to get the option. You can use get_blog_option() etc to get options from the non-current blog.
network-wide options, which are shared between all sites on a network, and are stored in wp_sitemeta. These options are accessed with get_site_option(), update_site_option(), etc.
(Note that the 'site' terminology is a bit confusing: before WordPress 3.0 and the merge of WPMU, what we now call 'sites' were called 'blogs', and what we now call 'the network' (ie, the entire installation) was called 'the site'. That's why you use x_site_meta() to get networkwide stuff.)

If you are running Multisite, then registration is stored in wp_sitemeta. Thus the use of get_site_option().

If you are not running Multisite, there is no wp_sitemeta table, and the _site_option() functions simply fall back on _option(), so that get_site_option( 'registration' ) will return the value of get_option( 'registration' ).

For more on the options functions, see wp-includes/options.php https://core.trac.wordpress.org/browser/trunk/wp-includes/option.php (the option.php file was introduced recently into trunk; on a distribution version, look in wp-includes/functions.php).

  • web_development/wordpress/options.txt
  • Last modified: 2020/10/09 04:01
  • by jimboobrien