Sometimes you need to know the blog ID for a site on a WordPress multisite installation. The code below displays that information in the site footer along with a few other useful snippets such as the number of queries and page creation time. This is ideal for inside an mu-plugin.

Hopefully this is of use to somebody out there. I use it regularly to track various things within WordPress multisite installations, so thought I should share it with everyone.

<?php

/*
 * Leaves an HTML comment in the footer with the current blogs' ID
 */
function comment_current_blog_id() {
	global $blog_id;

	echo '<!-- Blog ' . $blog_id . ' was created in ';
	timer_stop( 1 );
	echo ' seconds via ' . get_num_queries() . ' queries -->';
}
add_action( 'wp_footer', 'comment_current_blog_id' );