Using WordPress ‘refresh_blog_details()’ PHP function

The refresh_blog_details WordPress PHP function clears the blog details cache.

Usage

To use the refresh_blog_details function, simply provide the blog ID as an argument:

refresh_blog_details($blog_id);

Parameters

  • $blog_id (int) – Optional. Blog ID. Defaults to the current blog.

More information

See WordPress Developer Resources: refresh_blog_details

Examples

Refresh the current blog details

This example clears the cache for the current blog:

refresh_blog_details();

Refresh the details of a specific blog

This example clears the cache for a specific blog with the ID 42:

$blog_id = 42;
refresh_blog_details($blog_id);

Refresh the details of all blogs in a multisite setup

This example clears the cache for all blogs in a multisite WordPress installation:

$blogs = get_sites();
foreach ($blogs as $blog) {
    refresh_blog_details($blog->blog_id);
}

Refresh blog details when a post is updated

This example clears the cache for the current blog when a post is updated, using the save_post action:

function my_refresh_blog_details_on_post_update() {
    refresh_blog_details();
}
add_action('save_post', 'my_refresh_blog_details_on_post_update');

Refresh blog details when a theme is changed

This example clears the cache for the current blog when a theme is changed, using the switch_theme action:

function my_refresh_blog_details_on_theme_switch() {
    refresh_blog_details();
}
add_action('switch_theme', 'my_refresh_blog_details_on_theme_switch');