Skip to content

Instantly share code, notes, and snippets.

@iandunn
Last active November 7, 2015 21:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save iandunn/c5a983d1a9d4b09d6d20 to your computer and use it in GitHub Desktop.
Save iandunn/c5a983d1a9d4b09d6d20 to your computer and use it in GitHub Desktop.
/*
* 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