get_site_meta()WP 5.1.0

Retrieves metadata for a site.

No Hooks.

Return

Mixed. An array of values if $single is false. The value of meta data field if $single is true. False for an invalid $site_id (non-numeric, zero, or negative value). An empty string if a valid but non-existing site ID is passed.

Usage

get_site_meta( $site_id, $key, $single );
$site_id(int) (required)
Site ID.
$key(string)
The meta key to retrieve. By default, returns data for all keys.
Default: ''
$single(true|false)
Whether to return a single value. This parameter has no effect if $key is not specified.
Default: false

Examples

0

#1 Demo: retrieve site (blog) metadata

// get the meta field of the site with ID 17, directly in the variable
$blog_meta = get_site_meta( 17, 'mykey', true );

// Get all values of the meta-field (with the same key) as an array
$blog_meta = get_site_meta( 14, 'mykey' );

// Get all the metadata of the site with ID 115, as an array
$blog_metas = get_site_meta( 115 );
0

#2 More examples

See get_post_meta().

Changelog

Since 5.1.0 Introduced.

get_site_meta() code WP 6.4.3

function get_site_meta( $site_id, $key = '', $single = false ) {
	return get_metadata( 'blog', $site_id, $key, $single );
}