• Resolved igornn

    (@igornn)


    Hi,
    great plugin, Thanks!

    now the question

    i am using multisite with more than 50 sites.
    when i make some changes in the template file, i need to go each site and click on clear cache button.

    how can i just loop over all sites and make clear cache by code?

    Thanks

    https://ww.wp.xz.cn/plugins/cachify/

Viewing 1 replies (of 1 total)
  • Hi there

    Thanks for reaching out. You could use something like this to clear the cache for all sites:

    if ( is_multisite() && class_exists( 'Cachify' ) ) {
    	foreach (wp_get_sites() as $site) {
    		switch_to_blog($site->bog_id);
    		Cachify::flush_total_cache();
    		restore_current_blog();
    	}
    }

    Note: This query is untested. You should be aware that looping through all sites and deleting their cache could take a while. However, with 50 sites that shouldn’t be a big deal.

Viewing 1 replies (of 1 total)

The topic ‘clear cache by code’ is closed to new replies.