0

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

1

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

| 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

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.