WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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
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
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
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 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.