Just recently I ran into a case where I had to quickly look something up in the database of my WordPress development environment. I typically do this via a program called Sequel Pro, which helps give some visualization to your database. I love Command Line tools, but sometimes I prefer the visuals to do some troubleshooting.

If you’ve ever looked at a WordPress database, you’ll typically see tables like wp_posts, wp_postameta, and wp_options. In multisite however, things like the posts table, postmeta and options are in tables that contain the blog_id, giving us wp_3_posts, wp_3_postmeta, and wp_3_options. No problem at all if your multisite only has a couple sites setup, but when you use it for your development environment, you get something like this:

Screen Shot 2015-02-20 at 11.32.51 AM

Determining what blog ID you are looking at, isn’t quite easy. So here’s a quick snippet that will drop the current blog ID in the admin header, like so:

Screen Shot 2015-02-20 at 11.35.06 AM

function kfg_toolbar_blog_id( $wp_admin_bar ) {
	$args = array(
		'id'    => 'blog_id',
		'title' => 'Blog #' . get_current_blog_id()
	$wp_admin_bar->add_node( $args );
add_action( 'admin_bar_menu', 'kfg_toolbar_blog_id', 999 );

Posted by Chris Klosowski

Chris Klosowski is the President of Easy Digital Downloads, the easiest way to sell your digital products with WordPress. Trusted by over 50,000 smart store owners.