Currently I have created a multisite for my client. Within the network, there are a (primary)corporate site, a newsbites site and a blog site. Is there a way to query the primary site link, so that newsbites and blog site can connect back to the (primary) corporate site, without hard coding the site url?


Use network_home_url( $path = '', $scheme = null ).
You can see it in /wp-includes/link-template.php.


// Root of main site
$network_home = network_home_url();

// About page on main site
$network_about = network_home_url( 'about/' );

In a network, the main site has always the same ID as the network ID. network_home_url() uses get_current_site() which return the global variable (sigh) $current_site, an instance of stdClass. This one is filled in wp-includes/ms-settings.php, which in turn is loaded in wp-settings.php before mu-plugins are loaded.

So you can rely on it in your plugin or theme.

  • I tried.... It actually bring me back to the child homepage. Or perhaps I wrote it wrongly? Below how I type the code... <a href="<?php network_home_url( $path = '', $scheme = null );?>" class="mainBrand"><img src="<?php bloginfo( 'template_directory' ) ?>/images/brand.svg" ></a> – user57831 Aug 11 '14 at 13:38
  • Use network_home_url() without any parameters if you don’t want to change them. – fuxia Aug 11 '14 at 13:40
  • Toscho, I afraid will hate me. No luck even I do it without parameters. Wordpress just direct me back to the current site home page. I actually wished to have the link call back to the main Primary site. Just like when you signup an acc with wp.com, ppl can click on wp icon to go back to wp.com site. not the main acc site. – user57831 Aug 11 '14 at 20:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.