Support » Networking WordPress » get_site_url function not getting the correct blog_id

  • Resolved eduardosan


    Hi everybody,

    I’ve been digging for a long time in this problem, and I don’t know what else to do. I have a multisite install and the dashboard on wp-admin shows an strange bheaviour on internal blogs. On root blog (/) everything works fine. However, when acess any other dashboard (such as /teste/wp-admin) the following happens:

    1 – The edit post link on posts list is broken. It doesn’t show the right post URL
    2 – The categories are also broken, because they show the category from the main blog
    3 – Media upload is also not working. Instead of pointing to the site’s media upload link (/teste/wp-admin/media-upload.php) the link points to main site (/wp-admin/media-upload.php)

    Debugging the code I found the main reason: the function get_admin_url calls get_site_url passing $blog_id as null, and get_site_url doesn’t get the actual blog ID. As it doesn’t get the actual blog_id, all the links are pointing to main site instead of pointing to the blog.

    It also affects categories, tags and everything else on the metaboxes, because all the options are rendered form the main site.

    The following check fails on get_site_url:

    if ( empty( $blog_id ) || !is_multisite() )
    $url = get_option( 'siteurl' );
    $url = get_blog_option( $blog_id, 'siteurl' );

    $blog_id should be a global var and hold the actual blog_id, but it’s empty at this point.

    I’m out of options here. Can someone give a light so I know at least where to search for answers?

Viewing 5 replies - 1 through 5 (of 5 total)
  • Moderator Ipstenu (Mika Epstein)


    Lead Plugin Wrangler

    What’s in your .htaccess?

    Hi Mika,

    This is my .htaccess:

    # Begin Worpdress Multisite
    RewriteEngine On
    RewriteBase /
    RewriteRule ^index\.php$ - [L]
    # uploaded files
    RewriteRule ^([_0-9a-zA-Z-]+/)?files/(.+) wp-includes/ms-files.php?file=$2 [L]
    # add a trailing slash to /wp-admin
    RewriteRule ^([_0-9a-zA-Z-]+/)?wp-admin$ $1wp-admin/ [R=301,L]
    RewriteCond %{REQUEST_FILENAME} -f [OR]
    RewriteCond %{REQUEST_FILENAME} -d
    RewriteRule ^ - [L]
    RewriteRule  ^([_0-9a-zA-Z-]+/)?(wp-(content|admin|includes).*) $2 [L]
    RewriteRule  ^([_0-9a-zA-Z-]+/)?(.*\.php)$ $2 [L]
    RewriteRule . /index.php [L]
    # END WordPress

    I have tried already many changes on this file, and it doesn’t seem to be the problem.

    Can you tell me how this $blog_id is set for this function (get_site_url)? Maybe it helps me to find a solution.

    Moderator Ipstenu (Mika Epstein)


    Lead Plugin Wrangler

    You should never need to make any changes to how get_site_url works…

    Is this a brand new install?

    Hi Mika,

    Yes, this is a brand new install. Any clue about the problem?

    Hi Mika,

    Just to let you know: I’ve upgraded WordPress to version 3.5 and Buddypress to version 1.6.2 and the problem disappeared. Everything is working fine now!

    BTW, it’s an excelent version.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘get_site_url function not getting the correct blog_id’ is closed to new replies.