Show Site ID Columns in MultiSite

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: http://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://www.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['site_id'] = __('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);
?>
StudioPress Theme of the Month

Comments

  1. I really need this, but I’m not a programmer. Where do I put this?

    Thanks,
    J

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

  2. Thank you Ipstenu for the code! Just what I need. :)

  3. Ipstenu.
    May I add my thanks for writing that useful little script. Saved my sanity… for now!

  4. ;-) 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.

    :smile: :smile: :smile:

    • 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.

  5. EXCELLENT!!
    Thank you.

Half-Elf? Try Half OFF WordPress ebooks!