How to add ‘total’ value to custom column title on the posts list page

I have added custom column to all posts page by this code:

// ADD NEW COLUMN
function len_columns_head($defaults) {
    $defaults['post_len'] = 'Symbols';
    return $defaults;
}
 
// SHOW POST LENGTH
function len_columns_content($column_name, $post_ID) {
    if ($column_name == 'post_len') {
        $post    = get_post($post_ID); 
        $content = $post->post_content;
        $length  = strlen($content);
        if ($length) {
            echo $length.' symbols';
        }
    }
}

add_filter('manage_posts_columns', 'len_columns_head');
add_action('manage_posts_custom_column', 'len_columns_content', 10, 2);

but now i need to add total count of symbols to column title like this: “Symbols, 123456 total”. How can i achieve this? I have tried to add global variable to functions.php and add $length to it on every len_columns_content call, but that didn’t work

Go to Source
Author: dmitry