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

In the functions.php of my plugin I've added the following code:

function relativePathForUploads( $fileinfo )
    global $blog_id;
    $path = get_blog_option($blog_id,'siteurl');

    $fileinfo['url'] = str_replace($path,'',$fileinfo['url']);

    return $fileinfo;

add_filter('wp_handle_upload', 'relativePathForUploads');

But in the error log I get the following message:

PHP Fatal error:  Call to undefined function get_blog_option()

Do I need to include something before I'm able to call get_blog_option? If so, what?

share|improve this question
up vote 7 down vote accepted

I think that function is only available in multisite mode. Try:

  $path = get_blog_option($blog_id,'siteurl');
  $path = get_option('siteurl');`
share|improve this answer
Thanks! Makes perfect sense, why else would you need a blog Id. Must have missed it in the reference manual. – Luke Jul 7 '11 at 2:52

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.