Last active
November 7, 2015 21:33
-
-
Save iandunn/c5a983d1a9d4b09d6d20 to your computer and use it in GitHub Desktop.
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
/* | |
* This is old and doesn't always work correctly, see the following post for a better way: | |
* | |
* https://iandunn.name/flushing-rewrite-rules-on-all-sites-in-a-multisite-network/ | |
*/ | |
function flush_rewrite_rules_everywhere() { | |
global $wp_rewrite; | |
$sites = wp_get_sites( array( 'limit' => false ) ); | |
foreach ( $sites as $site_id ) { | |
switch_to_blog( $site_id ); | |
$wp_rewrite->init(); | |
flush_rewrite_rules(); | |
restore_current_blog(); | |
} | |
$wp_rewrite->init(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment