Is there a function to check if a WordPress multisite install uses the subdirectory or subdomain option when new blogs get created?
I’m using the function wpmu_create_blog to create new blogs.
The Codex explains:
On subdirectory installs, $domain is the same as the main site’s domain, and the path is the subdirectory name (eg ‘example.com’ and ‘/blog1/’). On subdomain installs, $domain is the new subdomain + root domain (eg ‘blog1.example.com’), and $path is ‘/’.
So I would need a way to find out if the multisite is a subdirectory or subdomain install.
Well, we have the very constant defined in
wp-config.php
:You can use
wp_get_sites()
to get information about your blogs. It will return an array containing information about all existing blogs.Example result from the documentation:
[0] will be your main blog, so I’d ignore this. But by checking the first blog after that you should be able to get the information.
Of course this only works when there is at least one additional blog created, but I couldn’t find any other option to check for.