Skip to content

Instantly share code, notes, and snippets.

@yratof
Created September 1, 2021 11:11
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yratof/1e16da7e375c0a1bc278fb46e9bcf7c0 to your computer and use it in GitHub Desktop.
Save yratof/1e16da7e375c0a1bc278fb46e9bcf7c0 to your computer and use it in GitHub Desktop.
Show the site_name on sites.php with multisite wordpress
<?php
/* Add site_name as a column */
add_filter( 'wpmu_blogs_columns', 'add_useful_columns' );
function add_useful_columns( $site_columns ) {
$site_columns['site_name'] = 'Site Name';
return $site_columns;
}
/* Populate site_name with blogs site_name */
add_action( 'manage_sites_custom_column', 'column_site_name' , 10, 2 );
function column_site_name( $column_name, $blog_id ) {
$current_blog_details = get_blog_details( array( 'blog_id' => $blog_id ) );
echo ucwords( $current_blog_details->blogname );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment