Problem with Links after switch_to_blog()


it looks like the Domain Mapping Plugin does not load when there are no mappings set up for the current blog.
The problem with this behaviour is that you get wrong permalinks after switching with switch_to_blog() to a blog with mappings set up.

Blog ID: 1, Main URL:, Mapping: none
Blog ID: 2, Main URL:, Mapping:
If you now open and you use the following code get_permalink() returns the URL with instead of

echo get_permalink();

I temporary fixed this issue by inserting a row into the wp_domain_mapping table manually via phpMyAdmin and mapping the domain onto itself. (see screenshot)
This forces the Domain Mapping plugin to load and the above code works correctly.

Please fix this issue by hooking into switch_to_blog() and loading the plugin if needed. Another solution would be to give the user a option to force loading the plugin also if there is no mapping for the current blog.

Best regards,
Stefan Reisinger <>
Lorem Ipsum GmbH