Error getting correct blog_id on MU from functions.php

Compare $current_site->id with $current_site->blog_id. According to the in-line documentation, blog_id should be working … but check to see if there’s a major difference there (your system might have a plug-in or something else causing a problem).


Update – Ignore last

It seems like $current_site is a global variable defined by your site or network and will always return the same blog_id as your network dashboard – in this case, “1.”

What you need to use instead is $current_blog:

function get_image_list() {
    global $current_blog;
    $dir=is_multisite() ?  'wp-content/blogs.dir/'.$current_blog->blog_id.'/files/' : 'wp-content/uploads/';
    $url=is_multisite() ?  get_bloginfo('url').'/wp-content/blogs.dir/'.$current_blog->blog_id.'/files/' : get_bloginfo('url').'/wp-content/uploads/';

That should get you the right information.

Leave a Comment