W3cubDocs

/WordPress

wpdb::get_blog_prefix( int $blog_id = null ): string

Gets blog prefix.

Parameters

$blog_idintoptional
Blog ID to retrieve the table prefix for.
Defaults to the current blog ID.

Default:null

Return

string Blog prefix.

Source

public function get_blog_prefix( $blog_id = null ) {
	if ( is_multisite() ) {
		if ( null === $blog_id ) {
			$blog_id = $this->blogid;
		}

		$blog_id = (int) $blog_id;

		if ( defined( 'MULTISITE' ) && ( 0 === $blog_id || 1 === $blog_id ) ) {
			return $this->base_prefix;
		} else {
			return $this->base_prefix . $blog_id . '_';
		}
	} else {
		return $this->base_prefix;
	}
}

Changelog

Version Description
3.0.0 Introduced.

© 2003–2024 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/classes/wpdb/get_blog_prefix