Site and blog terminology in WordPress Multisite


WordPress Multisite is a great feature because you save time with the installation and upgrade of WordPress, themes and plugins by having a collection of sites sharing the same WordPress installation. However, the lack of detailed documentation and the uses of different terms for the same purpose in the dashboard and the WPMU functions can lead a confusion at the time of programming.
The dashboard uses the term “site” for each sub-domain or sub-directory installed in the network.

On the other hand, WPMU functions use the term site for the network and the term blog for each sub-domain or sub-directory. With the description of the WPMU function get_current_site, you might think that this function will get information of your current site viewed.

<!--?php <br ?--> $site = get_current_site();
echo 'You are viewing the current site
ID: '
.$site-&gt;id
.'
Domain: '
.$site-&gt;domain
.'
Path: '
.$site-&gt;path
.'
Site name: '
.$site-&gt;site_name;
?&gt;

However, you get information of the network.

You are viewing the current site
ID: 1
Domain: localhost
Path: /wordpress/
Site name: My Blog Test Multisite

To get information of your current site viewed, the right function to use is get_blog_details but you need to pass the blog id as a parameter. If you don’t know the blog id, you have to use the global variable $blog_id.

Note: You can also get the blog id by using the function get_id_from_blogname. However, it doesn’t retrieve the id for the main site. It only works for the subdomain or sudirectories.

<!--?php <br ?--> global $blog_id;
$site = get_blog_details($blog_id);
echo 'You are viewing the current site
Site ID:'
.$site-&gt;site_id
.'
Blog ID: '
. $site-&gt;blog_id
.'
Domain: '
.$site-&gt;domain
.'
Path: '
.$site-&gt;path
.'
Blog name: '
.$site-&gt;blogname;
?&gt;

With the use of this function, you finally get the information of the current site viewed.

You are viewing the current site
Site ID:1
Blog ID: 2
Domain: localhost
Path: /wordpress/boroniatest/
Blog name: Boronia Test

You can also use the global variables to obtain the same information as get_current_site and get_blog_details WPMU functions.

Global Variable Functions
$current_site get_current_site
$current_blog get_current_blog

Moreover, you should be aware that the objects returning information for the site or blog don’t contain the same amount of variables but some variable names are the same as domain and path. For more detailed information, check those links:

About Boronia Technologies

Boronia Technologies is the business name of Catherine Lebastard, an IT professional with extensive experience in web development and database administration. Catherine chose the name of Boronia as she likes flowers and purple color. The logo of her business is inspired on Boronia flower plus digital elements incorated inside the flower.


Why you should use my services?

Because I can guide you to the right path and provide you what you are looking for at the right price according to your budget. Also, I am able to develop or debug an application with any programming language that you request because I have the ability to learn at extremely fast pace and adapt easily to progress in technology.