Created
May 14, 2020 12:03
-
-
Save AubreyHewes/b80413959767a73c0291510722ce5c9e to your computer and use it in GitHub Desktop.
WordPress "Multiple Domain" & WPML compatability fix
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Configured "Multiple Domain" plugin does not redirect root properly when working with WPML... | |
* | |
* X.nl -> / | |
* Y.nl -> / | |
* X.com -> /en/ | |
* Y.com -> /en/ | |
*/ | |
function fix_multiple_domain_plugin_redirects() { | |
if (strpos(MULTIPLE_DOMAIN_DOMAIN, '.com') === false) { | |
return; | |
} | |
if (is_home() || is_front_page() || empty($_SERVER['REQUEST_URI']) || $_SERVER['REQUEST_URI'] === '/') { | |
wp_redirect(home_url() . '/en/'); | |
exit; | |
} | |
} | |
add_action('init', 'fix_multiple_domain_plugin_redirects', 1); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment