Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

How can one determine, from functions.php, the blog-id of the site (or alternately, the path to the media directory)?

share|improve this question
add comment

1 Answer

up vote 1 down vote accepted

For the current site, you can use the $current_site global variable and look at the blog_id member variable, e.g. $current_site->blog_id

share|improve this answer
    
Thanks mtekk, I've updated my question with your answer and my script. –  Scott B Nov 18 '10 at 17:59
    
I can't get $current_site->blog_id to echo anything –  Scott B Nov 19 '10 at 12:25
1  
Inside a function you'll need to globalise the var else it's outside the scope of the function.. ie. global $current_site; –  t31os Nov 19 '10 at 12:41
    
You'll need to globalise it, as t31os said, even if you are calling it just in the functions.php file. –  mtekk Nov 19 '10 at 16:57
2  
FYI $GLOBALS['current_site']->blog_id will work without using the globals keyword first. It also has the advantage of being clearly global everywhere you use it. –  Steve Clay Dec 8 '10 at 23:25
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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