views:

57

answers:

2

I have a network of blogs that link to each other. The problem is when I want to get the primary blog's domain. I need it for things like the the target of the logo when clicked.

I can't seem to find a function in WPMU the retrieves this. I can see the value I want in the wp_site table. I could easily get it with $wpdb, but its a bit over kill, and if there is a function that can get the value already, then I want to use it.

I would prefer a solution that does not use a hardcoded ID as this can change if the root blog is deleted and/or replaced.

+1  A: 

How about get_blogaddress_by_id(1)? This would get the URL for the blog with ID 1 (which is the primary blog by default).

Check out wp-includes/wpmu-functions.php for similar functions.

Note, this might all change with the codebase merge in 3.0.

UPDATE

If you want the site install blog, use the global object $current_site ($current_site->ID). If you want the 'dashboard blog', use get_site_option('dashboard_blog').

TheDeadMedic
I would prefer a solution that does not use an ID as this can change if the root blog is deleted and/or replaced.
Robert Hurst
My apologies, I skim read the question and missed the last part. Check my revised answer.
TheDeadMedic
Thanks for your help, this is a good solution.~Cheers
Robert Hurst
Whenever I get stuck like this, I do print_r($GLOBALS);die(); somewhere and look at the output to see if I can get the global value I need. You'll be amazed what's there, already ready to go.
Volomike
A: 
<?php
echo 'You are viewing '.get_current_site()->domain;
?> 

see the doc

pixeline
My mistake, this returns the current site, I want the root site.
Robert Hurst