wordpresssubdomainsubdirectory

Find out if Wordpress multisite uses subdirectory or subdomain for new blogs


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.


Solution

  • Well, we have the very constant defined in wp-config.php:

    if ( defined( 'SUBDOMAIN_INSTALL' ) ) 
    {
        if( SUBDOMAIN_INSTALL )
            echo '<h2>Is: SUBDOMAIN</h2>';
        else
            echo '<h2>Is: SUBDIRECTORY</h2>';
    }