Correcting the WordPress multisite URL when using domain mapping

I have come across a small problem in WordPress multisite. When using a mapping to a custom domain, the domain is apparently mapped but internally the site retains your main domain with a sub-domain as its address. So, while externally it may be “”, internally it is still “”. Usually, this does not cause any trouble but you may run into unexpected problems with more advanced stuff and some plugins may function incorrectly.

I came across this when trying to configure Facebook with Social Networks Auto-Poster (SNAP) plugin. The plugin will issue an OAuth request to Facebook but the request fails because the plugin uses the “” instead of “” as you would expect. So Facebook understandably rejects the request to authorize. And this same thing may happen in other places.

The site URL comes from the database, options “siteurl” and “home”. Fire up your favorite SQL tool and head for the database. Find your table wp_XX_options where the site in question is stored (XX being the id of the site, they simply get numbered from 1 up). Change the two options to the correct URLs and things should start looking up.


Remember to change the URLs back to “” when you remove the domain mapping.… -->

continue reading →

WordPress Multisite – Getting the correct link to the site

The WordPress multisite install is a great thing. Except when you come across something that works not the way you expect.

So, the WordPress multisite installed on with blogs on subdomain basis will give you sites with names like and Of course, we all like nice looking domain names, so you install a mapping plugin and get the domain map to your and it all just works… So now you happily access your blog at Great. Until you run into trouble because internally your blog’s site address is still And the calls to get_site_url(), home_url(), admin_url() and so on still return you the old original name of your site before mapping, in my case the

This sucks and I could not find a solution to this weird problem. The only thing that came to mind was to use the actual site URL from the request and recompose the URL manually like this:

$adminurl = get_admin_url($path);
$admURL = parse_url($adminurl, PHP_URL_SCHEME) . "://" . 
    parse_url($adminurl, $component = PHP_URL_PATH);

I would not call it a beautiful solution or even a proper one but it works. It is amazing that you cannot get the right URL from anywhere. Oh, and why you need it? Well, if you are going to post to, let’s say, Facebook, for example, with something like the SNAP plugin, you better have the right URL for your site or else…… -->

continue reading →