Categories
How To

Show Site ID Columns in MultiSite

WordPress 3.1 removed them. I don’t use ’em but people kvetched so I wrote this over a ‘smoke break.’

This is totally a use at your own risk sort of thing. I really have no plans to do anything with it, and no, you cannot sort by ID due to limitations in how the columns work in WordPress.

Installation Instructions
Make a file called show-site-ids.php, put this code in it, and upload to your mu-plugins folder.

<?php
/*
Plugin Name: Show Site ID
Plugin URI: https://halfelf.org/hacks/site-id-columns-multisite/
Description: Show Site ID in Sites Column for Multisite
Version: 1.0
Author: Mika 'Ipstenu' Epstein
Author URI: http://ipstenu.org/

        This plugin is free software; you can redistribute it and/or modify
        it under the terms of the GNU General Public License as published by
        the Free Software Foundation; either version 2 of the License, or
        (at your option) any later version.

        This plugin is distributed in the hope that it will be useful,
        but WITHOUT ANY WARRANTY; without even the implied warranty of
        MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
        GNU General Public License for more details.

*/

function siteid_columns($column, $blog_id) {
        global $wpdb;
        if ( $column == 'site_id' ) {
                echo $blog_id;
        }
        return $value;
}

// Add in a column header
function site_id($columns) {
    $columns&#91;'site_id'&#93; = __('ID', 'site_id');
    return $columns;
}

        add_filter( 'wpmu_blogs_columns', 'site_id' );
        add_action('manage_sites_custom_column',  'siteid_columns', 10, 3);
        add_action('manage_blogs_custom_column',  'siteid_columns', 10, 3);
?>

7 replies on “Show Site ID Columns in MultiSite”

Make a folder called mu-plugins in your wp-content folder. Put this file (named whatever you want) in there. It’ll magically run 🙂

😉 Many Thanks

I was wondering a long time how to get the stupid id visible.

I think the code above misses a php ending statement. ?>

Or is the some more code left?

Once again thanks for putting me into the right direction.

🙂 🙂 🙂

Not missing. You actually don’t need the end call for PHP, and by leaving it out, it prevents people from having a headers already sent error. You can put it if you want, though.

Comments are closed.