-
-
Save 2ndkauboy/390cd5e76bfd9d5492078a515bfdd1db to your computer and use it in GitHub Desktop.
This file contains 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
<?php | |
/* | |
* Multisite Main-Site Redirect | |
* @package MultisiteMainSiteRedirect | |
* @author Bernhard Kau | |
* @license GPLv3 | |
* | |
* @wordpress-plugin | |
* Plugin Name: Multisite Main-Site Redirect | |
* Plugin URI: https://kau-boys.de | |
* Description: Redirect the main site of a multisite to another domain or sub-site | |
* Version: 0.1 | |
* Author: Bernhard Kau | |
* Author URI: https://kau-boys.de | |
* License: GPLv3 | |
* License URI: http://www.gnu.org/licenses/gpl-3.0.txt | |
*/ | |
function multisite_mainsite_redirect() { | |
if ( is_main_site() && ! is_admin() && 'wp-login.php' != $GLOBALS['pagenow'] && ! defined( 'WP_CLI' ) ) { | |
wp_redirect( 'http://example.com/' ); | |
exit(); | |
} | |
} | |
add_action( 'init', 'multisite_mainsite_redirect' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment